2007-04-01 18:36:23 +00:00
|
|
|
/***************************************************************************
|
2011-02-04 14:57:33 +00:00
|
|
|
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
2007-04-01 18:36:23 +00:00
|
|
|
* Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
|
|
|
|
* Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
|
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
* *
|
|
|
|
* This program 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 this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "dolphinmainwindow.h"
|
|
|
|
|
2007-06-19 19:17:32 +00:00
|
|
|
#include <config-nepomuk.h>
|
2007-05-18 23:51:03 +00:00
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
#include "dolphinapplication.h"
|
2010-12-31 10:59:46 +00:00
|
|
|
#include "dolphindockwidget.h"
|
2010-01-25 07:58:24 +00:00
|
|
|
#include "dolphincontextmenu.h"
|
2010-08-27 05:26:27 +00:00
|
|
|
#include "dolphinnewfilemenu.h"
|
2007-06-07 21:10:48 +00:00
|
|
|
#include "dolphinviewcontainer.h"
|
2010-07-24 22:08:30 +00:00
|
|
|
#include "mainwindowadaptor.h"
|
2010-10-29 13:41:26 +00:00
|
|
|
#ifdef HAVE_NEPOMUK
|
2011-03-09 18:18:25 +00:00
|
|
|
#include "panels/search/searchpanel.h"
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <Nepomuk/ResourceManager>
|
2010-10-29 13:41:26 +00:00
|
|
|
#endif
|
2009-01-14 20:14:36 +00:00
|
|
|
#include "panels/folders/folderspanel.h"
|
|
|
|
#include "panels/places/placespanel.h"
|
|
|
|
#include "panels/information/informationpanel.h"
|
2011-02-02 18:36:08 +00:00
|
|
|
#include "search/dolphinsearchinformation.h"
|
2010-07-24 22:08:30 +00:00
|
|
|
#include "settings/dolphinsettings.h"
|
|
|
|
#include "settings/dolphinsettingsdialog.h"
|
2009-08-01 20:01:51 +00:00
|
|
|
#include "statusbar/dolphinstatusbar.h"
|
2010-07-24 22:08:30 +00:00
|
|
|
#include "views/dolphinviewactionhandler.h"
|
|
|
|
#include "views/dolphinremoteencoding.h"
|
|
|
|
#include "views/draganddrophelper.h"
|
|
|
|
#include "views/viewproperties.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-03-10 17:33:30 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2009-01-14 20:14:36 +00:00
|
|
|
#include "panels/terminal/terminalpanel.h"
|
2008-03-10 17:33:30 +00:00
|
|
|
#endif
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
#include "dolphin_generalsettings.h"
|
2007-12-04 20:56:42 +00:00
|
|
|
#include "dolphin_iconsmodesettings.h"
|
2011-03-10 22:17:55 +00:00
|
|
|
#include "dolphin_searchsettings.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KAction>
|
|
|
|
#include <KActionCollection>
|
|
|
|
#include <KActionMenu>
|
|
|
|
#include <KConfig>
|
|
|
|
#include <KDesktopFile>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <kdeversion.h>
|
2010-12-31 10:59:46 +00:00
|
|
|
#include <kdualaction.h>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KFileDialog>
|
|
|
|
#include <KFilePlacesModel>
|
|
|
|
#include <KGlobal>
|
|
|
|
#include <KLineEdit>
|
2009-01-19 13:17:33 +00:00
|
|
|
#include <ktoolbar.h>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KIcon>
|
|
|
|
#include <KIconLoader>
|
|
|
|
#include <KIO/NetAccess>
|
2011-02-04 19:42:42 +00:00
|
|
|
#include <KInputDialog>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KLocale>
|
|
|
|
#include <KProtocolManager>
|
|
|
|
#include <KMenu>
|
|
|
|
#include <KMenuBar>
|
|
|
|
#include <KMessageBox>
|
|
|
|
#include <KFileItemListProperties>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <konqmimedata.h>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KProtocolInfo>
|
|
|
|
#include <KRun>
|
|
|
|
#include <KShell>
|
|
|
|
#include <KStandardDirs>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <kstatusbar.h>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KStandardAction>
|
2008-04-12 15:09:46 +00:00
|
|
|
#include <ktabbar.h>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KToggleAction>
|
|
|
|
#include <KUrlNavigator>
|
|
|
|
#include <KUrl>
|
|
|
|
#include <KUrlComboBox>
|
2011-02-04 19:42:42 +00:00
|
|
|
#include <KToolInvocation>
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-07-26 19:09:17 +00:00
|
|
|
#include <QDBusMessage>
|
2007-12-16 19:25:59 +00:00
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QSplitter>
|
2009-03-09 19:50:32 +00:00
|
|
|
#include <kacceleratormanager.h>
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2009-03-01 12:20:23 +00:00
|
|
|
/*
|
|
|
|
* Remembers the tab configuration if a tab has been closed.
|
|
|
|
* Each closed tab can be restored by the menu
|
|
|
|
* "Go -> Recently Closed Tabs".
|
|
|
|
*/
|
|
|
|
struct ClosedTab
|
|
|
|
{
|
|
|
|
KUrl primaryUrl;
|
|
|
|
KUrl secondaryUrl;
|
|
|
|
bool isSplit;
|
|
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(ClosedTab)
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
DolphinMainWindow::DolphinMainWindow(int id) :
|
2007-05-06 17:41:49 +00:00
|
|
|
KXmlGuiWindow(0),
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu(0),
|
2007-11-18 14:37:57 +00:00
|
|
|
m_showMenuBar(0),
|
2008-04-12 15:09:46 +00:00
|
|
|
m_tabBar(0),
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer(0),
|
2008-04-12 15:09:46 +00:00
|
|
|
m_centralWidgetLayout(0),
|
2008-03-29 14:54:56 +00:00
|
|
|
m_id(id),
|
2008-04-12 15:09:46 +00:00
|
|
|
m_tabIndex(0),
|
|
|
|
m_viewTab(),
|
2009-01-13 18:06:15 +00:00
|
|
|
m_actionHandler(0),
|
2009-03-25 22:00:50 +00:00
|
|
|
m_remoteEncoding(0),
|
2010-01-20 11:26:39 +00:00
|
|
|
m_settingsDialog(0),
|
2010-10-27 17:08:02 +00:00
|
|
|
m_lastHandleUrlStatJob(0),
|
2011-03-09 18:18:25 +00:00
|
|
|
m_searchDockIsTemporaryVisible(false)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2010-09-20 19:52:40 +00:00
|
|
|
// Workaround for a X11-issue in combination with KModifierInfo
|
|
|
|
// (see DolphinContextMenu::initializeModifierKeyInfo() for
|
|
|
|
// more information):
|
|
|
|
DolphinContextMenu::initializeModifierKeyInfo();
|
|
|
|
|
2008-03-21 17:24:06 +00:00
|
|
|
setObjectName("Dolphin#");
|
2008-04-12 15:09:46 +00:00
|
|
|
|
|
|
|
m_viewTab.append(ViewTab());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
new MainWindowAdaptor(this);
|
|
|
|
QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);
|
|
|
|
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
|
2008-04-20 22:07:44 +00:00
|
|
|
undoManager->setUiInterface(new UndoUiInterface());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
connect(undoManager, SIGNAL(undoAvailable(bool)),
|
|
|
|
this, SLOT(slotUndoAvailable(bool)));
|
|
|
|
connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
|
|
|
|
this, SLOT(slotUndoTextChanged(const QString&)));
|
2008-10-01 21:39:35 +00:00
|
|
|
connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)),
|
|
|
|
this, SLOT(clearStatusBar()));
|
|
|
|
connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
|
|
|
|
this, SLOT(showCommand(CommandType)));
|
2007-06-15 00:52:25 +00:00
|
|
|
connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)),
|
2008-11-08 16:22:30 +00:00
|
|
|
this, SLOT(showErrorMessage(const QString&)));
|
2008-11-13 17:22:35 +00:00
|
|
|
connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString&)),
|
|
|
|
this, SLOT(showErrorMessage(const QString&)));
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DolphinMainWindow::~DolphinMainWindow()
|
|
|
|
{
|
|
|
|
DolphinApplication::app()->removeMainWindow(this);
|
|
|
|
}
|
|
|
|
|
2009-12-17 21:07:18 +00:00
|
|
|
void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
|
|
|
|
{
|
|
|
|
if (dirs.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-08 21:25:53 +00:00
|
|
|
if (dirs.count() == 1) {
|
|
|
|
m_activeViewContainer->setUrl(dirs.first());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-17 21:07:18 +00:00
|
|
|
const int oldOpenTabsCount = m_viewTab.count();
|
|
|
|
|
|
|
|
const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
|
|
|
|
const bool hasSplitView = generalSettings->splitView();
|
|
|
|
|
|
|
|
// Open each directory inside a new tab. If the "split view" option has been enabled,
|
|
|
|
// always show two directories within one tab.
|
|
|
|
QList<KUrl>::const_iterator it = dirs.begin();
|
|
|
|
while (it != dirs.end()) {
|
|
|
|
openNewTab(*it);
|
|
|
|
++it;
|
|
|
|
|
|
|
|
if (hasSplitView && (it != dirs.end())) {
|
|
|
|
const int tabIndex = m_viewTab.count() - 1;
|
|
|
|
m_viewTab[tabIndex].secondaryView->setUrl(*it);
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove the previously opened tabs
|
|
|
|
for (int i = 0; i < oldOpenTabsCount; ++i) {
|
|
|
|
closeTab(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::openFiles(const QList<KUrl>& files)
|
|
|
|
{
|
2009-12-17 21:14:38 +00:00
|
|
|
if (files.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-17 21:07:18 +00:00
|
|
|
// Get all distinct directories from 'files' and open a tab
|
|
|
|
// for each directory. If the "split view" option is enabled, two
|
|
|
|
// directories are shown inside one tab (see openDirectories()).
|
|
|
|
QList<KUrl> dirs;
|
|
|
|
foreach (const KUrl& url, files) {
|
|
|
|
const KUrl dir(url.directory());
|
|
|
|
if (!dirs.contains(dir)) {
|
|
|
|
dirs.append(dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
openDirectories(dirs);
|
|
|
|
|
|
|
|
// Select the files. Although the files can be split between several
|
|
|
|
// tabs, there is no need to split 'files' accordingly, as
|
|
|
|
// the DolphinView will just ignore invalid selections.
|
|
|
|
const int tabCount = m_viewTab.count();
|
|
|
|
for (int i = 0; i < tabCount; ++i) {
|
|
|
|
m_viewTab[i].primaryView->view()->markUrlsAsSelected(files);
|
2011-02-09 18:21:58 +00:00
|
|
|
if (m_viewTab[i].secondaryView) {
|
2009-12-17 21:07:18 +00:00
|
|
|
m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-01 21:39:35 +00:00
|
|
|
void DolphinMainWindow::showCommand(CommandType command)
|
2007-06-12 21:45:22 +00:00
|
|
|
{
|
2008-10-01 21:39:35 +00:00
|
|
|
DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
|
|
|
|
switch (command) {
|
|
|
|
case KIO::FileUndoManager::Copy:
|
2009-10-20 22:50:34 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Successfully copied."),
|
2008-10-01 21:39:35 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Move:
|
2009-10-20 22:50:34 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Successfully moved."),
|
2008-10-01 21:39:35 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Link:
|
2009-10-21 06:59:05 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Successfully linked."),
|
2008-10-01 21:39:35 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Trash:
|
2009-10-20 22:50:34 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Successfully moved to trash."),
|
2008-10-01 21:39:35 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Rename:
|
2009-10-20 22:50:34 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Successfully renamed."),
|
2008-10-01 21:39:35 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KIO::FileUndoManager::Mkdir:
|
|
|
|
statusBar->setMessage(i18nc("@info:status", "Created folder."),
|
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
void DolphinMainWindow::refreshViews()
|
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
|
2007-06-12 21:45:22 +00:00
|
|
|
|
|
|
|
// remember the current active view, as because of
|
|
|
|
// the refreshing the active view might change to
|
|
|
|
// the secondary view
|
|
|
|
DolphinViewContainer* activeViewContainer = m_activeViewContainer;
|
|
|
|
|
2008-10-07 18:37:59 +00:00
|
|
|
const int tabCount = m_viewTab.count();
|
|
|
|
for (int i = 0; i < tabCount; ++i) {
|
|
|
|
m_viewTab[i].primaryView->refresh();
|
2011-02-09 18:21:58 +00:00
|
|
|
if (m_viewTab[i].secondaryView) {
|
2008-10-07 18:37:59 +00:00
|
|
|
m_viewTab[i].secondaryView->refresh();
|
|
|
|
}
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setActiveViewContainer(activeViewContainer);
|
2010-11-05 17:02:58 +00:00
|
|
|
|
|
|
|
const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
|
|
|
|
if (generalSettings->modifiedStartupSettings()) {
|
|
|
|
// The startup settings have been changed by the user (see bug #254947).
|
2010-11-05 17:03:29 +00:00
|
|
|
// Synchronize the split-view setting with the active view:
|
2010-11-05 17:02:58 +00:00
|
|
|
const bool splitView = generalSettings->splitView();
|
|
|
|
const ViewTab& activeTab = m_viewTab[m_tabIndex];
|
2011-02-09 18:21:58 +00:00
|
|
|
const bool toggle = ( splitView && !activeTab.secondaryView)
|
|
|
|
|| (!splitView && activeTab.secondaryView);
|
2010-11-05 17:02:58 +00:00
|
|
|
if (toggle) {
|
|
|
|
toggleSplitView();
|
|
|
|
}
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-03-29 14:54:56 +00:00
|
|
|
void DolphinMainWindow::pasteIntoFolder()
|
|
|
|
{
|
|
|
|
m_activeViewContainer->view()->pasteIntoFolder();
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::changeUrl(const KUrl& url)
|
|
|
|
{
|
2008-10-07 22:05:55 +00:00
|
|
|
if (!KProtocolManager::supportsListing(url)) {
|
2008-10-07 20:29:18 +00:00
|
|
|
// The URL navigator only checks for validity, not
|
|
|
|
// if the URL can be listed. An error message is
|
|
|
|
// shown due to DolphinViewContainer::restoreView().
|
|
|
|
return;
|
|
|
|
}
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2007-06-13 17:08:39 +00:00
|
|
|
DolphinViewContainer* view = activeViewContainer();
|
2011-02-09 18:21:58 +00:00
|
|
|
if (view) {
|
2007-06-13 17:08:39 +00:00
|
|
|
view->setUrl(url);
|
2007-04-01 18:36:23 +00:00
|
|
|
updateEditActions();
|
|
|
|
updateViewActions();
|
|
|
|
updateGoActions();
|
2009-05-05 21:49:03 +00:00
|
|
|
setUrlAsCaption(url);
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab.count() > 1) {
|
2009-07-10 06:07:32 +00:00
|
|
|
m_tabBar->setTabText(m_tabIndex, squeezedText(tabName(m_activeViewContainer->url())));
|
2008-04-12 15:09:46 +00:00
|
|
|
}
|
2009-03-10 00:35:59 +00:00
|
|
|
const QString iconName = KMimeType::iconNameForUrl(url);
|
|
|
|
m_tabBar->setTabIcon(m_tabIndex, KIcon(iconName));
|
2007-10-20 17:05:16 +00:00
|
|
|
emit urlChanged(url);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-07 07:27:06 +00:00
|
|
|
void DolphinMainWindow::slotEditableStateChanged(bool editable)
|
|
|
|
{
|
|
|
|
KToggleAction* editableLocationAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
|
|
|
|
editableLocationAction->setChecked(editable);
|
|
|
|
}
|
|
|
|
|
2007-10-02 19:03:03 +00:00
|
|
|
void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
updateEditActions();
|
|
|
|
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
|
2008-07-26 13:49:50 +00:00
|
|
|
int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedItemsCount();
|
2011-02-09 18:21:58 +00:00
|
|
|
if (m_viewTab[m_tabIndex].secondaryView) {
|
2008-07-26 13:49:50 +00:00
|
|
|
selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedItemsCount();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QAction* compareFilesAction = actionCollection()->action("compare_files");
|
2007-12-18 15:08:59 +00:00
|
|
|
if (selectedUrlsCount == 2) {
|
2008-06-28 18:42:51 +00:00
|
|
|
compareFilesAction->setEnabled(isKompareInstalled());
|
2007-12-18 15:08:59 +00:00
|
|
|
} else {
|
|
|
|
compareFilesAction->setEnabled(false);
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
emit selectionChanged(selection);
|
|
|
|
}
|
|
|
|
|
2007-07-02 17:24:54 +00:00
|
|
|
void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
|
2007-05-17 14:51:54 +00:00
|
|
|
{
|
2007-07-02 17:24:54 +00:00
|
|
|
emit requestItemInfo(item);
|
2007-05-17 14:51:54 +00:00
|
|
|
}
|
|
|
|
|
2008-02-23 15:48:56 +00:00
|
|
|
void DolphinMainWindow::updateHistory()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2008-02-23 15:48:56 +00:00
|
|
|
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
|
|
|
const int index = urlNavigator->historyIndex();
|
|
|
|
|
|
|
|
QAction* backAction = actionCollection()->action("go_back");
|
2009-11-06 18:02:55 +00:00
|
|
|
backAction->setToolTip(i18nc("@info", "Go back"));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (backAction) {
|
2008-02-23 15:48:56 +00:00
|
|
|
backAction->setEnabled(index < urlNavigator->historySize() - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction* forwardAction = actionCollection()->action("go_forward");
|
2009-11-06 18:02:55 +00:00
|
|
|
forwardAction->setToolTip(i18nc("@info", "Go forward"));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (forwardAction) {
|
2008-02-23 15:48:56 +00:00
|
|
|
forwardAction->setEnabled(index > 0);
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateFilterBarAction(bool show)
|
|
|
|
{
|
2008-01-28 11:37:08 +00:00
|
|
|
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
|
2007-04-01 18:36:23 +00:00
|
|
|
showFilterBarAction->setChecked(show);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::openNewMainWindow()
|
|
|
|
{
|
|
|
|
DolphinApplication::app()->createMainWindow()->show();
|
|
|
|
}
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
void DolphinMainWindow::openNewTab()
|
|
|
|
{
|
2010-03-23 21:29:58 +00:00
|
|
|
const bool isUrlEditable = m_activeViewContainer->urlNavigator()->isUrlEditable();
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
openNewTab(m_activeViewContainer->url());
|
|
|
|
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2010-03-24 08:06:34 +00:00
|
|
|
// The URL navigator of the new tab should have the same editable state
|
|
|
|
// as the current tab
|
|
|
|
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
|
|
|
|
navigator->setUrlEditable(isUrlEditable);
|
|
|
|
|
2010-03-23 21:29:58 +00:00
|
|
|
if (isUrlEditable) {
|
|
|
|
// If a new tab is opened and the URL is editable, assure that
|
2008-12-01 20:56:00 +00:00
|
|
|
// the user can edit the URL without manually setting the focus
|
|
|
|
navigator->setFocus();
|
|
|
|
}
|
2008-04-12 15:09:46 +00:00
|
|
|
}
|
|
|
|
|
2008-04-12 16:12:57 +00:00
|
|
|
void DolphinMainWindow::openNewTab(const KUrl& url)
|
|
|
|
{
|
2010-01-11 09:21:16 +00:00
|
|
|
QWidget* focusWidget = QApplication::focusWidget();
|
|
|
|
|
2008-04-12 16:12:57 +00:00
|
|
|
if (m_viewTab.count() == 1) {
|
|
|
|
// Only one view is open currently and hence no tab is shown at
|
|
|
|
// all. Before creating a tab for 'url', provide a tab for the current URL.
|
2010-01-06 15:33:27 +00:00
|
|
|
const KUrl currentUrl = m_activeViewContainer->url();
|
|
|
|
m_tabBar->addTab(KIcon(KMimeType::iconNameForUrl(currentUrl)),
|
|
|
|
squeezedText(tabName(currentUrl)));
|
2008-04-13 20:20:30 +00:00
|
|
|
m_tabBar->blockSignals(false);
|
2008-04-12 16:12:57 +00:00
|
|
|
}
|
|
|
|
|
2010-01-06 15:33:27 +00:00
|
|
|
m_tabBar->addTab(KIcon(KMimeType::iconNameForUrl(url)),
|
|
|
|
squeezedText(tabName(url)));
|
2008-04-12 16:12:57 +00:00
|
|
|
|
|
|
|
ViewTab viewTab;
|
|
|
|
viewTab.splitter = new QSplitter(this);
|
2009-04-22 18:29:02 +00:00
|
|
|
viewTab.splitter->setChildrenCollapsible(false);
|
2011-03-26 15:37:13 +00:00
|
|
|
viewTab.primaryView = createViewContainer(url, viewTab.splitter);
|
2008-12-01 20:56:00 +00:00
|
|
|
viewTab.primaryView->setActive(false);
|
2008-04-12 16:12:57 +00:00
|
|
|
connectViewSignals(viewTab.primaryView);
|
|
|
|
|
|
|
|
m_viewTab.append(viewTab);
|
2008-09-29 21:00:34 +00:00
|
|
|
|
2008-08-12 18:59:25 +00:00
|
|
|
actionCollection()->action("close_tab")->setEnabled(true);
|
2008-12-12 20:30:23 +00:00
|
|
|
|
|
|
|
// provide a split view, if the startup settings are set this way
|
|
|
|
const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
|
|
|
|
if (generalSettings->splitView()) {
|
|
|
|
const int tabIndex = m_viewTab.count() - 1;
|
|
|
|
createSecondaryView(tabIndex);
|
|
|
|
m_viewTab[tabIndex].secondaryView->setActive(true);
|
|
|
|
m_viewTab[tabIndex].isPrimaryViewActive = false;
|
|
|
|
}
|
2010-01-11 09:21:16 +00:00
|
|
|
|
2011-02-09 18:21:58 +00:00
|
|
|
if (focusWidget) {
|
2010-01-11 09:21:16 +00:00
|
|
|
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
|
|
|
|
// in background, assure that the previous focused widget gets the focus back.
|
|
|
|
focusWidget->setFocus();
|
|
|
|
}
|
2008-04-12 16:12:57 +00:00
|
|
|
}
|
|
|
|
|
2008-10-25 09:00:28 +00:00
|
|
|
void DolphinMainWindow::activateNextTab()
|
|
|
|
{
|
2009-03-01 12:42:51 +00:00
|
|
|
if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
|
2008-10-25 09:00:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-25 09:21:20 +00:00
|
|
|
const int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count();
|
2008-10-25 09:00:28 +00:00
|
|
|
m_tabBar->setCurrentIndex(tabIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::activatePrevTab()
|
|
|
|
{
|
2009-03-01 12:42:51 +00:00
|
|
|
if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
|
2008-10-25 09:00:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-25 09:21:20 +00:00
|
|
|
int tabIndex = m_tabBar->currentIndex() - 1;
|
2008-10-25 09:00:28 +00:00
|
|
|
if (tabIndex == -1) {
|
|
|
|
tabIndex = m_tabBar->count() - 1;
|
|
|
|
}
|
|
|
|
m_tabBar->setCurrentIndex(tabIndex);
|
|
|
|
}
|
|
|
|
|
2008-10-25 10:32:55 +00:00
|
|
|
void DolphinMainWindow::openInNewTab()
|
|
|
|
{
|
|
|
|
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
|
2010-10-06 15:04:37 +00:00
|
|
|
if (list.isEmpty()) {
|
|
|
|
openNewTab(m_activeViewContainer->url());
|
|
|
|
} else if ((list.count() == 1) && list[0].isDir()) {
|
2010-10-10 11:11:45 +00:00
|
|
|
openNewTab(list[0].url());
|
2008-10-25 10:32:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::openInNewWindow()
|
|
|
|
{
|
2010-10-06 15:04:37 +00:00
|
|
|
KUrl newWindowUrl;
|
|
|
|
|
2008-10-25 10:32:55 +00:00
|
|
|
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
|
2010-10-06 15:04:37 +00:00
|
|
|
if (list.isEmpty()) {
|
|
|
|
newWindowUrl = m_activeViewContainer->url();
|
|
|
|
} else if ((list.count() == 1) && list[0].isDir()) {
|
2010-10-10 11:11:45 +00:00
|
|
|
newWindowUrl = list[0].url();
|
2010-10-06 15:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!newWindowUrl.isEmpty()) {
|
2008-10-25 10:32:55 +00:00
|
|
|
DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
|
2010-10-06 15:04:37 +00:00
|
|
|
window->changeUrl(newWindowUrl);
|
2008-10-25 10:32:55 +00:00
|
|
|
window->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
void DolphinMainWindow::toggleActiveView()
|
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!m_viewTab[m_tabIndex].secondaryView) {
|
2007-06-27 15:15:29 +00:00
|
|
|
// only one view is available
|
|
|
|
return;
|
2007-06-07 21:10:48 +00:00
|
|
|
}
|
2007-06-27 15:15:29 +00:00
|
|
|
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(m_activeViewContainer);
|
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
|
2007-06-27 15:15:29 +00:00
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
DolphinViewContainer* left = m_viewTab[m_tabIndex].primaryView;
|
|
|
|
DolphinViewContainer* right = m_viewTab[m_tabIndex].secondaryView;
|
2007-06-27 15:15:29 +00:00
|
|
|
setActiveViewContainer(m_activeViewContainer == right ? left : right);
|
2007-06-07 21:10:48 +00:00
|
|
|
}
|
|
|
|
|
2010-01-11 09:21:16 +00:00
|
|
|
void DolphinMainWindow::showEvent(QShowEvent* event)
|
|
|
|
{
|
|
|
|
KXmlGuiWindow::showEvent(event);
|
|
|
|
if (!event->spontaneous()) {
|
|
|
|
m_activeViewContainer->view()->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
|
|
|
DolphinSettings& settings = DolphinSettings::instance();
|
|
|
|
GeneralSettings* generalSettings = settings.generalSettings();
|
2009-03-12 22:40:32 +00:00
|
|
|
|
2009-08-13 18:54:16 +00:00
|
|
|
// Find out if Dolphin is closed directly by the user or
|
|
|
|
// by the session manager because the session is closed
|
|
|
|
bool closedByUser = true;
|
|
|
|
DolphinApplication *application = qobject_cast<DolphinApplication*>(qApp);
|
2009-08-20 15:47:38 +00:00
|
|
|
if (application && application->sessionSaving()) {
|
2009-08-13 18:54:16 +00:00
|
|
|
closedByUser = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_viewTab.count() > 1) && generalSettings->confirmClosingMultipleTabs() && closedByUser) {
|
2009-03-12 22:40:32 +00:00
|
|
|
// Ask the user if he really wants to quit and close all tabs.
|
|
|
|
// Open a confirmation dialog with 3 buttons:
|
|
|
|
// KDialog::Yes -> Quit
|
|
|
|
// KDialog::No -> Close only the current tab
|
|
|
|
// KDialog::Cancel -> do nothing
|
|
|
|
KDialog *dialog = new KDialog(this, Qt::Dialog);
|
|
|
|
dialog->setCaption(i18nc("@title:window", "Confirmation"));
|
|
|
|
dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel);
|
|
|
|
dialog->setModal(true);
|
|
|
|
dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit());
|
|
|
|
dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")));
|
|
|
|
dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel());
|
|
|
|
dialog->setDefaultButton(KDialog::Yes);
|
|
|
|
|
|
|
|
bool doNotAskAgainCheckboxResult = false;
|
|
|
|
|
2009-03-17 20:34:32 +00:00
|
|
|
const int result = KMessageBox::createKMessageBox(dialog,
|
2009-03-12 22:40:32 +00:00
|
|
|
QMessageBox::Warning,
|
|
|
|
i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
|
|
|
|
QStringList(),
|
|
|
|
i18n("Do not ask again"),
|
|
|
|
&doNotAskAgainCheckboxResult,
|
|
|
|
KMessageBox::Notify);
|
|
|
|
|
|
|
|
if (doNotAskAgainCheckboxResult) {
|
|
|
|
generalSettings->setConfirmClosingMultipleTabs(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (result) {
|
2009-03-17 20:34:32 +00:00
|
|
|
case KDialog::Yes:
|
2009-03-12 22:40:32 +00:00
|
|
|
// Quit
|
|
|
|
break;
|
|
|
|
case KDialog::No:
|
|
|
|
// Close only the current tab
|
2010-01-25 07:58:24 +00:00
|
|
|
closeTab();
|
2009-03-12 22:40:32 +00:00
|
|
|
default:
|
|
|
|
event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
generalSettings->setFirstRun(false);
|
|
|
|
|
|
|
|
settings.save();
|
|
|
|
|
2011-03-09 18:18:25 +00:00
|
|
|
if (m_searchDockIsTemporaryVisible) {
|
|
|
|
QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
|
|
|
|
if (searchDock) {
|
|
|
|
searchDock->hide();
|
2010-10-27 17:08:02 +00:00
|
|
|
}
|
2011-03-09 18:18:25 +00:00
|
|
|
m_searchDockIsTemporaryVisible = false;
|
2010-10-27 17:08:02 +00:00
|
|
|
}
|
|
|
|
|
2007-04-16 20:44:36 +00:00
|
|
|
KXmlGuiWindow::closeEvent(event);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-30 18:42:17 +00:00
|
|
|
void DolphinMainWindow::saveProperties(KConfigGroup& group)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2009-03-19 07:23:41 +00:00
|
|
|
const int tabCount = m_viewTab.count();
|
|
|
|
group.writeEntry("Tab Count", tabCount);
|
|
|
|
group.writeEntry("Active Tab Index", m_tabBar->currentIndex());
|
|
|
|
|
|
|
|
for (int i = 0; i < tabCount; ++i) {
|
|
|
|
const DolphinViewContainer* cont = m_viewTab[i].primaryView;
|
|
|
|
group.writeEntry(tabProperty("Primary URL", i), cont->url().url());
|
2010-01-25 07:58:24 +00:00
|
|
|
group.writeEntry(tabProperty("Primary Editable", i),
|
|
|
|
cont->urlNavigator()->isUrlEditable());
|
2009-03-19 07:23:41 +00:00
|
|
|
|
|
|
|
cont = m_viewTab[i].secondaryView;
|
2011-02-09 18:21:58 +00:00
|
|
|
if (cont) {
|
2009-03-19 07:23:41 +00:00
|
|
|
group.writeEntry(tabProperty("Secondary URL", i), cont->url().url());
|
2010-01-25 07:58:24 +00:00
|
|
|
group.writeEntry(tabProperty("Secondary Editable", i),
|
|
|
|
cont->urlNavigator()->isUrlEditable());
|
2009-03-19 07:23:41 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-30 18:42:17 +00:00
|
|
|
void DolphinMainWindow::readProperties(const KConfigGroup& group)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2009-03-19 07:23:41 +00:00
|
|
|
const int tabCount = group.readEntry("Tab Count", 1);
|
|
|
|
for (int i = 0; i < tabCount; ++i) {
|
|
|
|
DolphinViewContainer* cont = m_viewTab[i].primaryView;
|
2007-11-30 18:42:17 +00:00
|
|
|
|
2009-03-19 07:23:41 +00:00
|
|
|
cont->setUrl(group.readEntry(tabProperty("Primary URL", i)));
|
|
|
|
const bool editable = group.readEntry(tabProperty("Primary Editable", i), false);
|
|
|
|
cont->urlNavigator()->setUrlEditable(editable);
|
2007-11-30 18:42:17 +00:00
|
|
|
|
2009-03-19 07:23:41 +00:00
|
|
|
cont = m_viewTab[i].secondaryView;
|
|
|
|
const QString secondaryUrl = group.readEntry(tabProperty("Secondary URL", i));
|
|
|
|
if (!secondaryUrl.isEmpty()) {
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!cont) {
|
2009-03-19 07:23:41 +00:00
|
|
|
// a secondary view should be shown, but no one is available
|
|
|
|
// currently -> create a new view
|
|
|
|
toggleSplitView();
|
|
|
|
cont = m_viewTab[i].secondaryView;
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(cont);
|
2009-03-19 07:23:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cont->setUrl(secondaryUrl);
|
|
|
|
const bool editable = group.readEntry(tabProperty("Secondary Editable", i), false);
|
|
|
|
cont->urlNavigator()->setUrlEditable(editable);
|
2011-02-09 18:21:58 +00:00
|
|
|
} else if (cont) {
|
2009-03-19 07:23:41 +00:00
|
|
|
// no secondary view should be shown, but the default setting shows
|
|
|
|
// one already -> close the view
|
2007-04-01 18:36:23 +00:00
|
|
|
toggleSplitView();
|
|
|
|
}
|
2007-11-30 18:42:17 +00:00
|
|
|
|
2009-03-19 07:23:41 +00:00
|
|
|
// openNewTab() needs to be called only tabCount - 1 times
|
|
|
|
if (i != tabCount - 1) {
|
|
|
|
openNewTab();
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2009-03-19 07:23:41 +00:00
|
|
|
|
|
|
|
const int index = group.readEntry("Active Tab Index", 0);
|
|
|
|
m_tabBar->setCurrentIndex(index);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateNewMenu()
|
|
|
|
{
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
|
|
|
|
m_newFileMenu->checkUpToDate();
|
|
|
|
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2009-03-26 18:44:36 +00:00
|
|
|
void DolphinMainWindow::createDirectory()
|
|
|
|
{
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
|
|
|
|
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
|
|
|
|
m_newFileMenu->createDirectory();
|
2009-03-26 18:44:36 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::quit()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2008-11-08 16:22:30 +00:00
|
|
|
void DolphinMainWindow::showErrorMessage(const QString& message)
|
2007-06-15 00:52:25 +00:00
|
|
|
{
|
|
|
|
if (!message.isEmpty()) {
|
|
|
|
DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
|
|
|
|
statusBar->setMessage(message, DolphinStatusBar::Error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::slotUndoAvailable(bool available)
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (undoAction) {
|
2007-04-01 18:36:23 +00:00
|
|
|
undoAction->setEnabled(available);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-01 01:38:20 +00:00
|
|
|
void DolphinMainWindow::restoreClosedTab(QAction* action)
|
|
|
|
{
|
2009-03-01 12:42:51 +00:00
|
|
|
if (action->data().toBool()) {
|
|
|
|
// clear all actions except the "Empty Recently Closed Tabs"
|
|
|
|
// action and the separator
|
|
|
|
QList<QAction*> actions = m_recentTabsMenu->menu()->actions();
|
|
|
|
const int count = actions.size();
|
2009-03-11 20:48:37 +00:00
|
|
|
for (int i = 2; i < count; ++i) {
|
2009-03-01 12:42:51 +00:00
|
|
|
m_recentTabsMenu->menu()->removeAction(actions.at(i));
|
2009-03-01 01:38:20 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const ClosedTab closedTab = action->data().value<ClosedTab>();
|
|
|
|
openNewTab(closedTab.primaryUrl);
|
|
|
|
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
|
|
|
|
|
|
|
if (closedTab.isSplit) {
|
2009-03-01 12:42:51 +00:00
|
|
|
// create secondary view
|
2009-03-01 01:38:20 +00:00
|
|
|
toggleSplitView();
|
|
|
|
m_viewTab[m_tabIndex].secondaryView->setUrl(closedTab.secondaryUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_recentTabsMenu->removeAction(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_recentTabsMenu->menu()->actions().count() == 2) {
|
|
|
|
m_recentTabsMenu->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
|
2011-02-09 18:21:58 +00:00
|
|
|
if (undoAction) {
|
2007-04-01 18:36:23 +00:00
|
|
|
undoAction->setText(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::undo()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
|
|
|
|
KIO::FileUndoManager::self()->undo();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::cut()
|
|
|
|
{
|
2007-11-15 20:04:05 +00:00
|
|
|
m_activeViewContainer->view()->cutSelectedItems();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::copy()
|
|
|
|
{
|
2007-11-15 20:04:05 +00:00
|
|
|
m_activeViewContainer->view()->copySelectedItems();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::paste()
|
|
|
|
{
|
2007-11-15 20:04:05 +00:00
|
|
|
m_activeViewContainer->view()->paste();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 16:37:07 +00:00
|
|
|
void DolphinMainWindow::find()
|
|
|
|
{
|
|
|
|
m_activeViewContainer->setSearchModeEnabled(true);
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::updatePasteAction()
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
2007-11-15 20:04:05 +00:00
|
|
|
QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
|
|
|
|
pasteAction->setEnabled(pasteInfo.first);
|
|
|
|
pasteAction->setText(pasteInfo.second);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::selectAll()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-12-16 19:25:59 +00:00
|
|
|
|
|
|
|
// if the URL navigator is editable and focused, select the whole
|
|
|
|
// URL instead of all items of the view
|
|
|
|
|
|
|
|
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
2009-05-26 18:52:14 +00:00
|
|
|
QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses
|
2007-12-16 19:25:59 +00:00
|
|
|
const bool selectUrl = urlNavigator->isUrlEditable() &&
|
|
|
|
lineEdit->hasFocus();
|
|
|
|
if (selectUrl) {
|
|
|
|
lineEdit->selectAll();
|
|
|
|
} else {
|
|
|
|
m_activeViewContainer->view()->selectAll();
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::invertSelection()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->invertSelection();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::toggleSplitView()
|
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!m_viewTab[m_tabIndex].secondaryView) {
|
2008-12-12 20:30:23 +00:00
|
|
|
createSecondaryView(m_tabIndex);
|
2008-05-04 18:40:06 +00:00
|
|
|
setActiveViewContainer(m_viewTab[m_tabIndex].secondaryView);
|
2008-07-22 17:36:52 +00:00
|
|
|
} else if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
|
2007-04-01 18:36:23 +00:00
|
|
|
// remove secondary view
|
2008-04-12 15:09:46 +00:00
|
|
|
m_viewTab[m_tabIndex].secondaryView->close();
|
|
|
|
m_viewTab[m_tabIndex].secondaryView->deleteLater();
|
|
|
|
m_viewTab[m_tabIndex].secondaryView = 0;
|
2008-05-04 18:40:06 +00:00
|
|
|
|
|
|
|
setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
|
2007-08-12 17:48:29 +00:00
|
|
|
} else {
|
2008-07-22 17:36:52 +00:00
|
|
|
// The primary view is active and should be closed. Hence from a users point of view
|
2007-08-12 17:48:29 +00:00
|
|
|
// the content of the secondary view should be moved to the primary view.
|
|
|
|
// From an implementation point of view it is more efficient to close
|
|
|
|
// the primary view and exchange the internal pointers afterwards.
|
2008-04-12 15:09:46 +00:00
|
|
|
|
|
|
|
m_viewTab[m_tabIndex].primaryView->close();
|
|
|
|
m_viewTab[m_tabIndex].primaryView->deleteLater();
|
|
|
|
m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
|
|
|
|
m_viewTab[m_tabIndex].secondaryView = 0;
|
2008-05-04 18:40:06 +00:00
|
|
|
|
|
|
|
setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-06-07 21:41:22 +00:00
|
|
|
|
|
|
|
updateViewActions();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::reloadView()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->reload();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::stopLoading()
|
2007-06-12 21:45:22 +00:00
|
|
|
{
|
2010-09-22 19:39:46 +00:00
|
|
|
m_activeViewContainer->view()->stopLoading();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::enableStopAction()
|
|
|
|
{
|
|
|
|
actionCollection()->action("stop")->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::disableStopAction()
|
|
|
|
{
|
|
|
|
actionCollection()->action("stop")->setEnabled(false);
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-11-07 14:55:33 +00:00
|
|
|
void DolphinMainWindow::showFilterBar()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2010-11-07 14:55:33 +00:00
|
|
|
m_activeViewContainer->setFilterBarVisible(true);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::toggleEditLocation()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
|
2008-01-28 11:37:08 +00:00
|
|
|
QAction* action = actionCollection()->action("editable_location");
|
2007-06-07 21:10:48 +00:00
|
|
|
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
2008-01-28 11:37:08 +00:00
|
|
|
urlNavigator->setUrlEditable(action->isChecked());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-10-25 09:41:39 +00:00
|
|
|
void DolphinMainWindow::replaceLocation()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2007-11-04 18:50:22 +00:00
|
|
|
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
|
|
|
|
navigator->setUrlEditable(true);
|
2011-01-17 17:39:36 +00:00
|
|
|
navigator->setFocus();
|
2008-02-16 22:05:34 +00:00
|
|
|
|
|
|
|
// select the whole text of the combo box editor
|
2009-05-26 18:52:14 +00:00
|
|
|
QLineEdit* lineEdit = navigator->editor()->lineEdit(); // krazy:exclude=qclasses
|
2011-01-16 21:18:18 +00:00
|
|
|
lineEdit->selectAll();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
void DolphinMainWindow::togglePanelLockState()
|
|
|
|
{
|
|
|
|
GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
|
|
|
|
|
|
|
|
const bool newLockState = !generalSettings->lockPanels();
|
|
|
|
foreach (QObject* child, children()) {
|
|
|
|
DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
|
2011-02-09 18:21:58 +00:00
|
|
|
if (dock) {
|
2010-12-31 10:59:46 +00:00
|
|
|
dock->setLocked(newLockState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
generalSettings->setLockPanels(newLockState);
|
|
|
|
}
|
|
|
|
|
2011-03-26 15:37:13 +00:00
|
|
|
void DolphinMainWindow::slotPlacesPanelVisibilityChanged(bool visible)
|
|
|
|
{
|
|
|
|
const int tabCount = m_viewTab.count();
|
|
|
|
for (int i = 0; i < tabCount; ++i) {
|
|
|
|
ViewTab& tab = m_viewTab[i];
|
|
|
|
Q_ASSERT(tab.primaryView);
|
|
|
|
tab.primaryView->urlNavigator()->setPlacesSelectorVisible(!visible);
|
|
|
|
if (tab.secondaryView) {
|
|
|
|
tab.secondaryView->urlNavigator()->setPlacesSelectorVisible(!visible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::goBack()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2010-11-05 17:02:58 +00:00
|
|
|
|
2010-07-08 19:46:56 +00:00
|
|
|
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
|
|
|
urlNavigator->goBack();
|
2010-11-05 17:02:58 +00:00
|
|
|
|
2010-07-08 19:46:56 +00:00
|
|
|
if (urlNavigator->locationState().isEmpty()) {
|
|
|
|
// An empty location state indicates a redirection URL,
|
|
|
|
// which must be skipped too
|
2010-11-05 17:02:58 +00:00
|
|
|
urlNavigator->goBack();
|
2010-07-08 19:46:56 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::goForward()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->urlNavigator()->goForward();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::goUp()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->urlNavigator()->goUp();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2009-11-09 17:50:21 +00:00
|
|
|
void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
|
|
|
|
{
|
|
|
|
// The default case (left button pressed) is handled in goBack().
|
2009-11-09 18:13:36 +00:00
|
|
|
if (buttons == Qt::MidButton) {
|
2009-11-09 17:50:21 +00:00
|
|
|
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
|
2010-01-25 07:58:24 +00:00
|
|
|
const int index = urlNavigator->historyIndex() + 1;
|
|
|
|
openNewTab(urlNavigator->locationUrl(index));
|
2009-11-09 17:50:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
|
|
|
|
{
|
|
|
|
// The default case (left button pressed) is handled in goForward().
|
2009-11-09 18:13:36 +00:00
|
|
|
if (buttons == Qt::MidButton) {
|
2009-11-09 17:50:21 +00:00
|
|
|
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
|
2010-01-25 07:58:24 +00:00
|
|
|
const int index = urlNavigator->historyIndex() - 1;
|
|
|
|
openNewTab(urlNavigator->locationUrl(index));
|
2009-11-09 17:50:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
|
|
|
|
{
|
|
|
|
// The default case (left button pressed) is handled in goUp().
|
2009-11-09 18:13:36 +00:00
|
|
|
if (buttons == Qt::MidButton) {
|
2009-11-09 17:50:21 +00:00
|
|
|
openNewTab(activeViewContainer()->url().upUrl());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::goHome()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->urlNavigator()->goHome();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::compareFiles()
|
|
|
|
{
|
|
|
|
// The method is only invoked if exactly 2 files have
|
|
|
|
// been selected. The selected files may be:
|
|
|
|
// - both in the primary view
|
|
|
|
// - both in the secondary view
|
|
|
|
// - one in the primary view and the other in the secondary
|
|
|
|
// view
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KUrl urlA;
|
|
|
|
KUrl urlB;
|
|
|
|
|
2010-10-10 11:11:45 +00:00
|
|
|
KFileItemList items = m_viewTab[m_tabIndex].primaryView->view()->selectedItems();
|
|
|
|
|
|
|
|
switch (items.count()) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case 0: {
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].secondaryView);
|
2010-10-10 11:11:45 +00:00
|
|
|
items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems();
|
2010-10-10 16:13:25 +00:00
|
|
|
Q_ASSERT(items.count() == 2);
|
2010-10-10 11:11:45 +00:00
|
|
|
urlA = items[0].url();
|
|
|
|
urlB = items[1].url();
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
case 1: {
|
2010-10-10 11:11:45 +00:00
|
|
|
urlA = items[0].url();
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].secondaryView);
|
2010-10-10 11:11:45 +00:00
|
|
|
items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems();
|
|
|
|
Q_ASSERT(items.count() == 1);
|
|
|
|
urlB = items[0].url();
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
case 2: {
|
2010-10-10 11:11:45 +00:00
|
|
|
urlA = items[0].url();
|
|
|
|
urlB = items[1].url();
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
default: {
|
|
|
|
// may not happen: compareFiles may only get invoked if 2
|
|
|
|
// files are selected
|
|
|
|
Q_ASSERT(false);
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString command("kompare -c \"");
|
|
|
|
command.append(urlA.pathOrUrl());
|
|
|
|
command.append("\" \"");
|
|
|
|
command.append(urlB.pathOrUrl());
|
|
|
|
command.append('\"');
|
2007-05-07 15:10:51 +00:00
|
|
|
KRun::runCommand(command, "Kompare", "kompare", this);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 14:37:57 +00:00
|
|
|
void DolphinMainWindow::toggleShowMenuBar()
|
|
|
|
{
|
|
|
|
const bool visible = menuBar()->isVisible();
|
|
|
|
menuBar()->setVisible(!visible);
|
|
|
|
}
|
|
|
|
|
2009-03-10 06:59:27 +00:00
|
|
|
void DolphinMainWindow::openTerminal()
|
|
|
|
{
|
2009-05-17 19:57:07 +00:00
|
|
|
QString dir(QDir::homePath());
|
|
|
|
|
|
|
|
// If the given directory is not local, it can still be the URL of an
|
|
|
|
// ioslave using UDS_LOCAL_PATH which to be converted first.
|
|
|
|
KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
|
|
|
|
|
|
|
|
//If the URL is local after the above conversion, set the directory.
|
|
|
|
if (url.isLocalFile()) {
|
|
|
|
dir = url.toLocalFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
KToolInvocation::invokeTerminal(QString(), dir);
|
2009-03-10 06:59:27 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::editSettings()
|
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!m_settingsDialog) {
|
2010-09-21 19:38:26 +00:00
|
|
|
const KUrl url = activeViewContainer()->url();
|
2009-01-17 18:42:06 +00:00
|
|
|
m_settingsDialog = new DolphinSettingsDialog(url, this);
|
2009-01-13 18:06:15 +00:00
|
|
|
m_settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
m_settingsDialog->show();
|
|
|
|
} else {
|
|
|
|
m_settingsDialog->raise();
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
void DolphinMainWindow::setActiveTab(int index)
|
|
|
|
{
|
|
|
|
Q_ASSERT(index >= 0);
|
|
|
|
Q_ASSERT(index < m_viewTab.count());
|
|
|
|
if (index == m_tabIndex) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// hide current tab content
|
2008-12-01 20:56:00 +00:00
|
|
|
ViewTab& hiddenTab = m_viewTab[m_tabIndex];
|
|
|
|
hiddenTab.isPrimaryViewActive = hiddenTab.primaryView->isActive();
|
|
|
|
hiddenTab.primaryView->setActive(false);
|
2011-02-09 18:21:58 +00:00
|
|
|
if (hiddenTab.secondaryView) {
|
2008-12-01 20:56:00 +00:00
|
|
|
hiddenTab.secondaryView->setActive(false);
|
|
|
|
}
|
2008-04-12 15:09:46 +00:00
|
|
|
QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
|
|
|
|
splitter->hide();
|
2008-04-13 19:18:54 +00:00
|
|
|
m_centralWidgetLayout->removeWidget(splitter);
|
2008-04-12 15:09:46 +00:00
|
|
|
|
|
|
|
// show active tab content
|
|
|
|
m_tabIndex = index;
|
|
|
|
|
|
|
|
ViewTab& viewTab = m_viewTab[index];
|
2009-10-17 19:33:36 +00:00
|
|
|
m_centralWidgetLayout->addWidget(viewTab.splitter, 1);
|
2008-04-12 15:09:46 +00:00
|
|
|
viewTab.primaryView->show();
|
2011-02-09 18:21:58 +00:00
|
|
|
if (viewTab.secondaryView) {
|
2008-04-12 15:09:46 +00:00
|
|
|
viewTab.secondaryView->show();
|
|
|
|
}
|
2008-04-13 19:18:54 +00:00
|
|
|
viewTab.splitter->show();
|
2008-04-12 15:09:46 +00:00
|
|
|
|
2008-04-13 19:12:52 +00:00
|
|
|
setActiveViewContainer(viewTab.isPrimaryViewActive ? viewTab.primaryView :
|
|
|
|
viewTab.secondaryView);
|
2008-04-12 15:09:46 +00:00
|
|
|
}
|
|
|
|
|
2008-04-16 20:03:05 +00:00
|
|
|
void DolphinMainWindow::closeTab()
|
|
|
|
{
|
|
|
|
closeTab(m_tabBar->currentIndex());
|
|
|
|
}
|
|
|
|
|
2008-04-13 20:20:30 +00:00
|
|
|
void DolphinMainWindow::closeTab(int index)
|
|
|
|
{
|
|
|
|
Q_ASSERT(index >= 0);
|
|
|
|
Q_ASSERT(index < m_viewTab.count());
|
|
|
|
if (m_viewTab.count() == 1) {
|
2009-03-01 12:42:51 +00:00
|
|
|
// the last tab may never get closed
|
2008-04-13 20:20:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == m_tabIndex) {
|
|
|
|
// The tab that should be closed is the active tab. Activate the
|
|
|
|
// previous tab before closing the tab.
|
2008-07-31 01:02:52 +00:00
|
|
|
m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
|
2008-04-13 20:20:30 +00:00
|
|
|
}
|
2009-03-01 01:38:20 +00:00
|
|
|
rememberClosedTab(index);
|
2009-03-01 12:42:51 +00:00
|
|
|
|
|
|
|
// delete tab
|
2008-04-13 20:20:30 +00:00
|
|
|
m_viewTab[index].primaryView->deleteLater();
|
2011-02-09 18:21:58 +00:00
|
|
|
if (m_viewTab[index].secondaryView) {
|
2008-04-13 20:20:30 +00:00
|
|
|
m_viewTab[index].secondaryView->deleteLater();
|
|
|
|
}
|
|
|
|
m_viewTab[index].splitter->deleteLater();
|
|
|
|
m_viewTab.erase(m_viewTab.begin() + index);
|
|
|
|
|
|
|
|
m_tabBar->blockSignals(true);
|
|
|
|
m_tabBar->removeTab(index);
|
|
|
|
|
|
|
|
if (m_tabIndex > index) {
|
|
|
|
m_tabIndex--;
|
|
|
|
Q_ASSERT(m_tabIndex >= 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if only one tab is left, also remove the tab entry so that
|
|
|
|
// closing the last tab is not possible
|
|
|
|
if (m_viewTab.count() == 1) {
|
|
|
|
m_tabBar->removeTab(0);
|
2008-08-12 18:59:25 +00:00
|
|
|
actionCollection()->action("close_tab")->setEnabled(false);
|
2008-04-13 20:20:30 +00:00
|
|
|
} else {
|
|
|
|
m_tabBar->blockSignals(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-16 20:03:05 +00:00
|
|
|
void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
|
|
|
|
{
|
2009-03-11 20:47:46 +00:00
|
|
|
KMenu menu(this);
|
2008-04-16 20:03:05 +00:00
|
|
|
|
2009-03-11 20:47:46 +00:00
|
|
|
QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
|
2008-04-16 20:03:05 +00:00
|
|
|
newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
|
|
|
|
|
2010-01-25 07:58:24 +00:00
|
|
|
QAction* detachTabAction = menu.addAction(KIcon("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
|
|
|
|
|
2009-03-11 20:47:46 +00:00
|
|
|
QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
|
2008-04-16 20:03:05 +00:00
|
|
|
|
2009-03-11 20:47:46 +00:00
|
|
|
QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
|
2008-04-16 20:03:05 +00:00
|
|
|
closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
|
2009-03-11 20:47:46 +00:00
|
|
|
QAction* selectedAction = menu.exec(pos);
|
2008-04-16 20:03:05 +00:00
|
|
|
if (selectedAction == newTabAction) {
|
|
|
|
const ViewTab& tab = m_viewTab[index];
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(tab.primaryView);
|
|
|
|
const KUrl url = tab.secondaryView && tab.secondaryView->isActive() ?
|
2008-04-16 21:27:39 +00:00
|
|
|
tab.secondaryView->url() : tab.primaryView->url();
|
2008-04-16 20:03:05 +00:00
|
|
|
openNewTab(url);
|
|
|
|
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
2010-01-25 07:58:24 +00:00
|
|
|
} else if (selectedAction == detachTabAction) {
|
|
|
|
const ViewTab& tab = m_viewTab[index];
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(tab.primaryView);
|
2010-01-25 07:58:24 +00:00
|
|
|
const KUrl primaryUrl = tab.primaryView->url();
|
|
|
|
DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
|
|
|
|
window->changeUrl(primaryUrl);
|
|
|
|
|
2011-02-09 18:21:58 +00:00
|
|
|
if (tab.secondaryView) {
|
2010-01-25 07:58:24 +00:00
|
|
|
const KUrl secondaryUrl = tab.secondaryView->url();
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!window->m_viewTab[0].secondaryView) {
|
2011-01-27 21:30:45 +00:00
|
|
|
window->toggleSplitView();
|
|
|
|
}
|
2010-01-25 07:58:24 +00:00
|
|
|
window->m_viewTab[0].secondaryView->setUrl(secondaryUrl);
|
|
|
|
if (tab.primaryView->isActive()) {
|
|
|
|
window->m_viewTab[0].primaryView->setActive(true);
|
|
|
|
} else {
|
|
|
|
window->m_viewTab[0].secondaryView->setActive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window->show();
|
|
|
|
closeTab(index);
|
2008-04-16 20:03:05 +00:00
|
|
|
} else if (selectedAction == closeOtherTabsAction) {
|
|
|
|
const int count = m_tabBar->count();
|
|
|
|
for (int i = 0; i < index; ++i) {
|
|
|
|
closeTab(0);
|
|
|
|
}
|
|
|
|
for (int i = index + 1; i < count; ++i) {
|
|
|
|
closeTab(1);
|
|
|
|
}
|
|
|
|
} else if (selectedAction == closeTabAction) {
|
|
|
|
closeTab(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-25 07:58:24 +00:00
|
|
|
void DolphinMainWindow::slotTabMoved(int from, int to)
|
|
|
|
{
|
|
|
|
m_viewTab.move(from, to);
|
|
|
|
m_tabIndex = m_tabBar->currentIndex();
|
|
|
|
}
|
|
|
|
|
2008-05-11 20:14:50 +00:00
|
|
|
void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons)
|
|
|
|
{
|
|
|
|
if (buttons & Qt::MidButton) {
|
|
|
|
openNewTab(url);
|
|
|
|
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
|
|
|
} else {
|
|
|
|
changeUrl(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-12 19:22:38 +00:00
|
|
|
void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& canDecode)
|
|
|
|
{
|
|
|
|
canDecode = KUrl::List::canDecode(event->mimeData());
|
|
|
|
}
|
|
|
|
|
2010-01-25 07:58:24 +00:00
|
|
|
void DolphinMainWindow::handleUrl(const KUrl& url)
|
|
|
|
{
|
2010-03-15 09:55:51 +00:00
|
|
|
delete m_lastHandleUrlStatJob;
|
|
|
|
m_lastHandleUrlStatJob = 0;
|
|
|
|
|
|
|
|
if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
|
|
|
|
activeViewContainer()->setUrl(url);
|
|
|
|
} else if (KProtocolManager::supportsListing(url)) {
|
|
|
|
// stat the URL to see if it is a dir or not
|
|
|
|
m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
|
|
|
|
connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)),
|
|
|
|
this, SLOT(slotHandleUrlStatFinished(KJob*)));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
new KRun(url, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
|
|
|
|
{
|
|
|
|
m_lastHandleUrlStatJob = 0;
|
|
|
|
const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
|
|
|
|
const KUrl url = static_cast<KIO::StatJob*>(job)->url();
|
2010-10-27 18:31:39 +00:00
|
|
|
if (entry.isDir()) {
|
2010-01-25 07:58:24 +00:00
|
|
|
activeViewContainer()->setUrl(url);
|
|
|
|
} else {
|
|
|
|
new KRun(url, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-23 07:26:02 +00:00
|
|
|
void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event)
|
|
|
|
{
|
|
|
|
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
|
|
|
|
if (!urls.isEmpty() && tab != -1) {
|
|
|
|
const ViewTab& viewTab = m_viewTab[tab];
|
|
|
|
const KUrl destPath = viewTab.isPrimaryViewActive ? viewTab.primaryView->url() : viewTab.secondaryView->url();
|
|
|
|
DragAndDropHelper::instance().dropUrls(KFileItem(), destPath, event, m_tabBar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-25 07:58:24 +00:00
|
|
|
void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
|
|
|
|
{
|
2010-08-27 05:26:27 +00:00
|
|
|
newFileMenu()->setEnabled(isFolderWritable);
|
2010-01-25 07:58:24 +00:00
|
|
|
}
|
|
|
|
|
2010-10-27 17:08:02 +00:00
|
|
|
void DolphinMainWindow::slotSearchModeChanged(bool enabled)
|
|
|
|
{
|
2010-11-12 12:34:51 +00:00
|
|
|
#ifdef HAVE_NEPOMUK
|
2011-02-02 18:36:08 +00:00
|
|
|
const KUrl url = m_activeViewContainer->url();
|
|
|
|
const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance();
|
|
|
|
if (!searchInfo.isIndexingEnabled() || !searchInfo.isPathIndexed(url)) {
|
2010-11-11 17:43:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-09 18:18:25 +00:00
|
|
|
QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
|
|
|
|
if (!searchDock) {
|
2010-10-27 17:08:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enabled) {
|
2011-03-09 18:18:25 +00:00
|
|
|
if (!searchDock->isVisible()) {
|
|
|
|
m_searchDockIsTemporaryVisible = true;
|
2010-10-27 17:08:02 +00:00
|
|
|
}
|
2011-03-09 18:18:25 +00:00
|
|
|
searchDock->show();
|
2010-10-27 17:08:02 +00:00
|
|
|
} else {
|
2011-03-09 18:18:25 +00:00
|
|
|
if (searchDock->isVisible() && m_searchDockIsTemporaryVisible) {
|
|
|
|
searchDock->hide();
|
2010-10-27 17:08:02 +00:00
|
|
|
}
|
2011-03-09 18:18:25 +00:00
|
|
|
m_searchDockIsTemporaryVisible = false;
|
2010-10-27 17:08:02 +00:00
|
|
|
}
|
2011-03-10 22:17:55 +00:00
|
|
|
|
|
|
|
SearchPanel* searchPanel = qobject_cast<SearchPanel*>(searchDock->widget());
|
|
|
|
if (searchPanel) {
|
|
|
|
// Per default any search-operation triggered by the Search Panel is done
|
|
|
|
// "Everywhere".
|
|
|
|
SearchPanel::SearchMode searchMode = SearchPanel::Everywhere;
|
|
|
|
|
|
|
|
if (enabled && (SearchSettings::location() == QLatin1String("FromHere"))) {
|
|
|
|
// Only if the search-mode is enabled it is visible for the user whether
|
|
|
|
// a searching is done "Everywhere" or "From Here" (= current directory).
|
|
|
|
searchMode = SearchPanel::FromCurrentDir;
|
|
|
|
}
|
|
|
|
searchPanel->setSearchMode(searchMode);
|
|
|
|
}
|
2010-11-12 12:34:51 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(enabled);
|
|
|
|
#endif
|
2010-10-27 17:08:02 +00:00
|
|
|
}
|
|
|
|
|
2010-01-25 07:58:24 +00:00
|
|
|
void DolphinMainWindow::openContextMenu(const KFileItem& item,
|
|
|
|
const KUrl& url,
|
|
|
|
const QList<QAction*>& customActions)
|
|
|
|
{
|
2010-10-25 13:45:34 +00:00
|
|
|
QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, item, url);
|
|
|
|
contextMenu->setCustomActions(customActions);
|
|
|
|
const DolphinContextMenu::Command command = contextMenu->open();
|
2010-09-22 20:24:49 +00:00
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
case DolphinContextMenu::OpenParentFolderInNewWindow: {
|
|
|
|
DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
|
|
|
|
window->changeUrl(item.url().upUrl());
|
|
|
|
window->show();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DolphinContextMenu::OpenParentFolderInNewTab:
|
|
|
|
openNewTab(item.url().upUrl());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DolphinContextMenu::None:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-10-25 13:45:34 +00:00
|
|
|
|
|
|
|
delete contextMenu;
|
2010-01-25 07:58:24 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::init()
|
|
|
|
{
|
2008-02-14 21:25:36 +00:00
|
|
|
DolphinSettings& settings = DolphinSettings::instance();
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
// Check whether Dolphin runs the first time. If yes then
|
|
|
|
// a proper default window size is given at the end of DolphinMainWindow::init().
|
2008-02-14 21:25:36 +00:00
|
|
|
GeneralSettings* generalSettings = settings.generalSettings();
|
2007-04-01 18:36:23 +00:00
|
|
|
const bool firstRun = generalSettings->firstRun();
|
|
|
|
if (firstRun) {
|
|
|
|
generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
m_viewTab[m_tabIndex].splitter = new QSplitter(this);
|
2009-04-22 18:29:02 +00:00
|
|
|
m_viewTab[m_tabIndex].splitter->setChildrenCollapsible(false);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
setupActions();
|
|
|
|
|
2010-09-21 19:38:26 +00:00
|
|
|
const KUrl homeUrl(generalSettings->homeUrl());
|
2009-05-05 21:49:03 +00:00
|
|
|
setUrlAsCaption(homeUrl);
|
2008-02-11 12:34:48 +00:00
|
|
|
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
|
|
|
|
connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
|
2009-03-26 18:44:36 +00:00
|
|
|
connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
|
2011-03-26 15:37:13 +00:00
|
|
|
|
|
|
|
m_viewTab[m_tabIndex].primaryView = createViewContainer(homeUrl, m_viewTab[m_tabIndex].splitter);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
|
|
|
|
connectViewSignals(m_activeViewContainer);
|
|
|
|
DolphinView* view = m_activeViewContainer->view();
|
|
|
|
m_activeViewContainer->show();
|
2008-02-11 12:34:48 +00:00
|
|
|
m_actionHandler->setCurrentView(view);
|
2009-03-26 18:44:36 +00:00
|
|
|
|
2009-03-25 22:00:50 +00:00
|
|
|
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
2009-03-26 18:44:36 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(const KUrl&)),
|
2009-03-25 22:00:50 +00:00
|
|
|
m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
m_tabBar = new KTabBar(this);
|
2009-02-22 17:06:15 +00:00
|
|
|
m_tabBar->setMovable(true);
|
|
|
|
m_tabBar->setTabsClosable(true);
|
2008-04-12 15:09:46 +00:00
|
|
|
connect(m_tabBar, SIGNAL(currentChanged(int)),
|
|
|
|
this, SLOT(setActiveTab(int)));
|
2009-03-01 18:19:38 +00:00
|
|
|
connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
|
2008-04-14 20:19:17 +00:00
|
|
|
this, SLOT(closeTab(int)));
|
2008-04-16 20:03:05 +00:00
|
|
|
connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
|
|
|
|
this, SLOT(openTabContextMenu(int, const QPoint&)));
|
2008-04-23 18:28:23 +00:00
|
|
|
connect(m_tabBar, SIGNAL(newTabRequest()),
|
|
|
|
this, SLOT(openNewTab()));
|
2008-08-12 19:22:38 +00:00
|
|
|
connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
|
|
|
|
this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
|
2009-02-10 20:48:16 +00:00
|
|
|
connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
|
|
|
|
this, SLOT(closeTab(int)));
|
2009-04-15 21:50:50 +00:00
|
|
|
connect(m_tabBar, SIGNAL(tabMoved(int, int)),
|
|
|
|
this, SLOT(slotTabMoved(int, int)));
|
2010-02-23 07:26:02 +00:00
|
|
|
connect(m_tabBar, SIGNAL(receivedDropEvent(int, QDropEvent*)),
|
|
|
|
this, SLOT(tabDropEvent(int, QDropEvent*)));
|
2009-01-30 06:13:11 +00:00
|
|
|
|
2008-04-13 20:20:30 +00:00
|
|
|
m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
|
2008-04-12 15:09:46 +00:00
|
|
|
|
|
|
|
QWidget* centralWidget = new QWidget(this);
|
|
|
|
m_centralWidgetLayout = new QVBoxLayout(centralWidget);
|
|
|
|
m_centralWidgetLayout->setSpacing(0);
|
|
|
|
m_centralWidgetLayout->setMargin(0);
|
|
|
|
m_centralWidgetLayout->addWidget(m_tabBar);
|
2009-10-17 19:24:05 +00:00
|
|
|
m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1);
|
2008-04-12 15:09:46 +00:00
|
|
|
|
|
|
|
setCentralWidget(centralWidget);
|
2007-04-01 18:36:23 +00:00
|
|
|
setupDockWidgets();
|
2008-10-15 06:03:41 +00:00
|
|
|
emit urlChanged(homeUrl);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-08-26 23:51:05 +00:00
|
|
|
setupGUI(Keys | Save | Create | ToolBar);
|
2007-04-01 18:36:23 +00:00
|
|
|
stateChanged("new_file");
|
|
|
|
|
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
|
|
|
connect(clipboard, SIGNAL(dataChanged()),
|
|
|
|
this, SLOT(updatePasteAction()));
|
|
|
|
|
2007-08-12 17:48:29 +00:00
|
|
|
if (generalSettings->splitView()) {
|
2007-06-20 15:46:57 +00:00
|
|
|
toggleSplitView();
|
|
|
|
}
|
2010-05-25 17:59:00 +00:00
|
|
|
updateEditActions();
|
2007-06-20 15:46:57 +00:00
|
|
|
updateViewActions();
|
2010-05-25 17:59:00 +00:00
|
|
|
updateGoActions();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-08-14 10:12:32 +00:00
|
|
|
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
|
|
|
|
showFilterBarAction->setChecked(generalSettings->filterBar());
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
if (firstRun) {
|
|
|
|
// assure a proper default size if Dolphin runs the first time
|
2008-03-20 21:10:27 +00:00
|
|
|
resize(750, 500);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-09-23 13:04:46 +00:00
|
|
|
m_showMenuBar->setChecked(!menuBar()->isHidden()); // workaround for bug #171080
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-02-11 12:34:48 +00:00
|
|
|
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
|
2007-06-12 21:45:22 +00:00
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
Q_ASSERT(viewContainer);
|
2008-04-12 15:09:46 +00:00
|
|
|
Q_ASSERT((viewContainer == m_viewTab[m_tabIndex].primaryView) ||
|
|
|
|
(viewContainer == m_viewTab[m_tabIndex].secondaryView));
|
2008-02-11 12:34:48 +00:00
|
|
|
if (m_activeViewContainer == viewContainer) {
|
2007-06-12 21:45:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_activeViewContainer->setActive(false);
|
2008-02-11 12:34:48 +00:00
|
|
|
m_activeViewContainer = viewContainer;
|
2008-04-13 19:12:52 +00:00
|
|
|
|
|
|
|
// Activating the view container might trigger a recursive setActiveViewContainer() call
|
|
|
|
// inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary
|
|
|
|
// disconnect the activated() signal in this case:
|
|
|
|
disconnect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
|
2007-06-12 21:45:22 +00:00
|
|
|
m_activeViewContainer->setActive(true);
|
2008-04-13 19:12:52 +00:00
|
|
|
connect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
|
2007-06-12 21:45:22 +00:00
|
|
|
|
2008-03-12 16:58:11 +00:00
|
|
|
m_actionHandler->setCurrentView(viewContainer->view());
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
updateHistory();
|
|
|
|
updateEditActions();
|
|
|
|
updateViewActions();
|
|
|
|
updateGoActions();
|
|
|
|
|
2010-09-21 19:38:26 +00:00
|
|
|
const KUrl url = m_activeViewContainer->url();
|
2009-05-05 21:49:03 +00:00
|
|
|
setUrlAsCaption(url);
|
2010-09-21 19:30:26 +00:00
|
|
|
if (m_viewTab.count() > 1) {
|
2008-04-16 20:03:05 +00:00
|
|
|
m_tabBar->setTabText(m_tabIndex, tabName(url));
|
2009-03-10 00:40:37 +00:00
|
|
|
m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url)));
|
2008-04-12 15:09:46 +00:00
|
|
|
}
|
2007-06-12 21:45:22 +00:00
|
|
|
|
2007-06-13 17:08:39 +00:00
|
|
|
emit urlChanged(url);
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
2011-03-26 15:37:13 +00:00
|
|
|
DolphinViewContainer* DolphinMainWindow::createViewContainer(const KUrl& url, QWidget* parent)
|
|
|
|
{
|
|
|
|
DolphinViewContainer* container = new DolphinViewContainer(url, parent);
|
|
|
|
|
|
|
|
// The places-selector from the URL navigator should only be shown
|
|
|
|
// if the places dock is invisible
|
|
|
|
QDockWidget* placesDock = findChild<QDockWidget*>("placesDock");
|
|
|
|
container->urlNavigator()->setPlacesSelectorVisible(!placesDock || !placesDock->isVisible());
|
|
|
|
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::setupActions()
|
|
|
|
{
|
|
|
|
// setup 'File' menu
|
2011-02-09 20:15:55 +00:00
|
|
|
m_newFileMenu = new DolphinNewFileMenu(this);
|
2010-08-27 05:26:27 +00:00
|
|
|
KMenu* menu = m_newFileMenu->menu();
|
2008-03-18 22:38:52 +00:00
|
|
|
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
|
2007-04-01 18:36:23 +00:00
|
|
|
menu->setIcon(KIcon("document-new"));
|
|
|
|
connect(menu, SIGNAL(aboutToShow()),
|
|
|
|
this, SLOT(updateNewMenu()));
|
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* newWindow = actionCollection()->addAction("new_window");
|
2007-04-01 18:36:23 +00:00
|
|
|
newWindow->setIcon(KIcon("window-new"));
|
2007-06-30 20:10:50 +00:00
|
|
|
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
|
2007-04-01 18:36:23 +00:00
|
|
|
newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
|
|
|
|
connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
KAction* newTab = actionCollection()->addAction("new_tab");
|
|
|
|
newTab->setIcon(KIcon("tab-new"));
|
|
|
|
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
|
2009-02-07 04:47:04 +00:00
|
|
|
newTab->setShortcut(KShortcut(Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N));
|
2008-04-12 15:09:46 +00:00
|
|
|
connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
|
|
|
|
|
2009-02-28 12:50:34 +00:00
|
|
|
KAction* closeTab = actionCollection()->addAction("close_tab");
|
2009-01-11 16:28:42 +00:00
|
|
|
closeTab->setIcon(KIcon("tab-close"));
|
|
|
|
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
|
2008-04-16 20:03:05 +00:00
|
|
|
closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
|
2008-08-12 18:59:25 +00:00
|
|
|
closeTab->setEnabled(false);
|
2008-04-16 20:03:05 +00:00
|
|
|
connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
KStandardAction::quit(this, SLOT(quit()), actionCollection());
|
|
|
|
|
|
|
|
// setup 'Edit' menu
|
|
|
|
KStandardAction::undo(this,
|
|
|
|
SLOT(undo()),
|
|
|
|
actionCollection());
|
|
|
|
|
2008-01-19 16:59:10 +00:00
|
|
|
// need to remove shift+del from cut action, else the shortcut for deletejob
|
|
|
|
// doesn't work
|
2007-11-02 20:50:05 +00:00
|
|
|
KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
|
|
|
|
KShortcut cutShortcut = cut->shortcut();
|
2011-02-27 22:06:14 +00:00
|
|
|
cutShortcut.remove(Qt::SHIFT | Qt::Key_Delete, KShortcut::KeepEmpty);
|
2007-11-02 20:50:05 +00:00
|
|
|
cut->setShortcut(cutShortcut);
|
2007-04-01 18:36:23 +00:00
|
|
|
KStandardAction::copy(this, SLOT(copy()), actionCollection());
|
2009-10-11 17:43:30 +00:00
|
|
|
KAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
|
|
|
|
// The text of the paste-action is modified dynamically by Dolphin
|
|
|
|
// (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
|
|
|
|
// due to the long text, the text "Paste" is used:
|
|
|
|
paste->setIconText(i18nc("@action:inmenu Edit", "Paste"));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-07-24 16:37:07 +00:00
|
|
|
KStandardAction::find(this, SLOT(find()), actionCollection());
|
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* selectAll = actionCollection()->addAction("select_all");
|
2007-06-30 20:10:50 +00:00
|
|
|
selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
|
2011-02-27 22:06:14 +00:00
|
|
|
selectAll->setShortcut(Qt::CTRL | Qt::Key_A);
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
|
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* invertSelection = actionCollection()->addAction("invert_selection");
|
2007-06-30 20:10:50 +00:00
|
|
|
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
|
2007-04-01 18:36:23 +00:00
|
|
|
invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
|
|
|
|
connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
|
|
|
|
|
|
|
|
// setup 'View' menu
|
2008-02-13 20:52:21 +00:00
|
|
|
// (note that most of it is set up in DolphinViewActionHandler)
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* split = actionCollection()->addAction("split_view");
|
2008-01-10 23:42:34 +00:00
|
|
|
split->setShortcut(Qt::Key_F3);
|
2007-08-12 17:48:29 +00:00
|
|
|
updateSplitAction();
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
|
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* reload = actionCollection()->addAction("reload");
|
2007-06-30 20:10:50 +00:00
|
|
|
reload->setText(i18nc("@action:inmenu View", "Reload"));
|
2007-04-01 18:36:23 +00:00
|
|
|
reload->setShortcut(Qt::Key_F5);
|
|
|
|
reload->setIcon(KIcon("view-refresh"));
|
|
|
|
connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
|
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* stop = actionCollection()->addAction("stop");
|
2007-06-30 20:10:50 +00:00
|
|
|
stop->setText(i18nc("@action:inmenu View", "Stop"));
|
2009-11-06 18:02:55 +00:00
|
|
|
stop->setToolTip(i18nc("@info", "Stop loading"));
|
2007-04-01 18:36:23 +00:00
|
|
|
stop->setIcon(KIcon("process-stop"));
|
|
|
|
connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
|
|
|
|
|
|
|
|
KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
|
2008-10-25 09:41:39 +00:00
|
|
|
showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
|
2007-04-01 18:36:23 +00:00
|
|
|
showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
|
|
|
|
connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
|
|
|
|
|
2008-10-25 09:41:39 +00:00
|
|
|
KAction* replaceLocation = actionCollection()->addAction("replace_location");
|
|
|
|
replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
|
|
|
|
replaceLocation->setShortcut(Qt::Key_F6);
|
|
|
|
connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation()));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
// setup 'Go' menu
|
2007-09-09 19:02:22 +00:00
|
|
|
KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
|
2009-11-09 17:50:21 +00:00
|
|
|
connect(backAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
|
2007-09-09 19:02:22 +00:00
|
|
|
KShortcut backShortcut = backAction->shortcut();
|
|
|
|
backShortcut.setAlternate(Qt::Key_Backspace);
|
|
|
|
backAction->setShortcut(backShortcut);
|
|
|
|
|
2009-03-11 22:41:57 +00:00
|
|
|
m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this);
|
2009-03-01 01:38:20 +00:00
|
|
|
m_recentTabsMenu->setIcon(KIcon("edit-undo"));
|
|
|
|
actionCollection()->addAction("closed_tabs", m_recentTabsMenu);
|
|
|
|
connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction *)),
|
|
|
|
this, SLOT(restoreClosedTab(QAction *)));
|
|
|
|
|
2009-03-11 22:41:57 +00:00
|
|
|
QAction* action = new QAction("Empty Recently Closed Tabs", m_recentTabsMenu);
|
2009-03-01 01:38:20 +00:00
|
|
|
action->setIcon(KIcon("edit-clear-list"));
|
|
|
|
action->setData(QVariant::fromValue(true));
|
|
|
|
m_recentTabsMenu->addAction(action);
|
|
|
|
m_recentTabsMenu->addSeparator();
|
|
|
|
m_recentTabsMenu->setEnabled(false);
|
|
|
|
|
2009-11-09 17:50:21 +00:00
|
|
|
KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
|
|
|
|
connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
|
|
|
|
|
|
|
|
KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection());
|
|
|
|
connect(upAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
KStandardAction::home(this, SLOT(goHome()), actionCollection());
|
|
|
|
|
|
|
|
// setup 'Tools' menu
|
2010-11-07 14:55:33 +00:00
|
|
|
KAction* showFilterBar = actionCollection()->addAction("show_filter_bar");
|
2007-06-30 20:10:50 +00:00
|
|
|
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
|
2009-08-30 08:33:59 +00:00
|
|
|
showFilterBar->setIcon(KIcon("view-filter"));
|
2007-05-07 05:33:20 +00:00
|
|
|
showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
|
2010-11-07 14:55:33 +00:00
|
|
|
connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* compareFiles = actionCollection()->addAction("compare_files");
|
2007-06-30 20:10:50 +00:00
|
|
|
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
|
2007-04-01 18:36:23 +00:00
|
|
|
compareFiles->setIcon(KIcon("kompare"));
|
|
|
|
compareFiles->setEnabled(false);
|
|
|
|
connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
|
|
|
|
|
2009-03-10 06:59:27 +00:00
|
|
|
KAction* openTerminal = actionCollection()->addAction("open_terminal");
|
|
|
|
openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
|
2009-05-26 18:39:25 +00:00
|
|
|
openTerminal->setIcon(KIcon("utilities-terminal"));
|
2009-03-10 06:59:27 +00:00
|
|
|
openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4);
|
|
|
|
connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
// setup 'Settings' menu
|
2010-11-09 00:15:14 +00:00
|
|
|
m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
|
2007-04-01 18:36:23 +00:00
|
|
|
KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
|
2008-10-25 09:00:28 +00:00
|
|
|
|
|
|
|
// not in menu actions
|
2010-03-22 18:48:12 +00:00
|
|
|
QList<QKeySequence> nextTabKeys;
|
|
|
|
nextTabKeys.append(KStandardShortcut::tabNext().primary());
|
2011-02-27 22:06:14 +00:00
|
|
|
nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab));
|
2010-03-22 18:48:12 +00:00
|
|
|
|
|
|
|
QList<QKeySequence> prevTabKeys;
|
|
|
|
prevTabKeys.append(KStandardShortcut::tabPrev().primary());
|
2011-02-27 22:06:14 +00:00
|
|
|
prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab));
|
2010-03-22 18:48:12 +00:00
|
|
|
|
2009-01-11 16:28:42 +00:00
|
|
|
KAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
|
2008-10-25 09:21:20 +00:00
|
|
|
activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
|
|
|
|
connect(activateNextTab, SIGNAL(triggered()), SLOT(activateNextTab()));
|
2010-03-22 18:48:12 +00:00
|
|
|
activateNextTab->setShortcuts(QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys);
|
2008-10-25 09:00:28 +00:00
|
|
|
|
2009-01-11 16:28:42 +00:00
|
|
|
KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
|
2008-10-25 09:21:20 +00:00
|
|
|
activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
|
|
|
|
connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab()));
|
2010-03-22 18:48:12 +00:00
|
|
|
activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys);
|
2008-10-25 10:32:55 +00:00
|
|
|
|
|
|
|
// for context menu
|
|
|
|
KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab");
|
|
|
|
openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
|
|
|
|
openInNewTab->setIcon(KIcon("tab-new"));
|
|
|
|
connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab()));
|
2008-12-12 06:55:26 +00:00
|
|
|
|
2008-10-25 10:32:55 +00:00
|
|
|
KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window");
|
|
|
|
openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
|
|
|
|
openInNewWindow->setIcon(KIcon("window-new"));
|
|
|
|
connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::setupDockWidgets()
|
|
|
|
{
|
2010-12-31 10:59:46 +00:00
|
|
|
const bool lock = DolphinSettings::instance().generalSettings()->lockPanels();
|
|
|
|
|
|
|
|
KDualAction* lockLayoutAction = actionCollection()->add<KDualAction>("lock_panels");
|
|
|
|
lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
|
|
|
|
lockLayoutAction->setActiveIcon(KIcon("object-unlocked"));
|
|
|
|
lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
|
|
|
|
lockLayoutAction->setInactiveIcon(KIcon("object-locked"));
|
|
|
|
lockLayoutAction->setActive(lock);
|
|
|
|
connect(lockLayoutAction, SIGNAL(triggered()), this, SLOT(togglePanelLockState()));
|
|
|
|
|
|
|
|
// Setup "Information"
|
|
|
|
DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
|
|
|
|
infoDock->setLocked(lock);
|
2007-04-01 18:36:23 +00:00
|
|
|
infoDock->setObjectName("infoDock");
|
|
|
|
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
2009-01-14 20:14:36 +00:00
|
|
|
Panel* infoPanel = new InformationPanel(infoDock);
|
2010-12-31 10:59:46 +00:00
|
|
|
infoPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
|
2009-11-25 20:53:37 +00:00
|
|
|
connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
|
2009-01-14 20:14:36 +00:00
|
|
|
infoDock->setWidget(infoPanel);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-05-03 17:46:34 +00:00
|
|
|
QAction* infoAction = infoDock->toggleViewAction();
|
2009-01-16 09:54:55 +00:00
|
|
|
infoAction->setIcon(KIcon("dialog-information"));
|
2010-05-03 17:46:34 +00:00
|
|
|
infoAction->setShortcut(Qt::Key_F11);
|
2010-12-19 12:48:24 +00:00
|
|
|
addActionCloneToCollection(infoAction, "show_information_panel");
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, infoDock);
|
2007-05-02 05:15:03 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
2009-01-14 20:14:36 +00:00
|
|
|
infoPanel, SLOT(setUrl(KUrl)));
|
2007-10-02 19:03:03 +00:00
|
|
|
connect(this, SIGNAL(selectionChanged(KFileItemList)),
|
2009-01-14 20:14:36 +00:00
|
|
|
infoPanel, SLOT(setSelection(KFileItemList)));
|
2007-07-02 17:24:54 +00:00
|
|
|
connect(this, SIGNAL(requestItemInfo(KFileItem)),
|
2009-01-14 20:14:36 +00:00
|
|
|
infoPanel, SLOT(requestDelayedItemInfo(KFileItem)));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Setup "Folders"
|
|
|
|
DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
|
|
|
|
foldersDock->setLocked(lock);
|
2009-01-14 20:14:36 +00:00
|
|
|
foldersDock->setObjectName("foldersDock");
|
|
|
|
foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
|
|
|
FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
|
2010-12-31 10:59:46 +00:00
|
|
|
foldersPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
|
2009-01-14 20:14:36 +00:00
|
|
|
foldersDock->setWidget(foldersPanel);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-05-03 17:46:34 +00:00
|
|
|
QAction* foldersAction = foldersDock->toggleViewAction();
|
2009-01-16 09:54:55 +00:00
|
|
|
foldersAction->setShortcut(Qt::Key_F7);
|
|
|
|
foldersAction->setIcon(KIcon("folder"));
|
2010-12-19 12:48:24 +00:00
|
|
|
addActionCloneToCollection(foldersAction, "show_folders_panel");
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2009-01-14 20:14:36 +00:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
|
2007-05-02 05:15:03 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
2009-01-14 20:14:36 +00:00
|
|
|
foldersPanel, SLOT(setUrl(KUrl)));
|
|
|
|
connect(foldersPanel, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)),
|
2008-05-11 21:51:04 +00:00
|
|
|
this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Setup "Terminal"
|
2008-03-10 17:33:30 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2010-12-31 10:59:46 +00:00
|
|
|
DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
|
|
|
|
terminalDock->setLocked(lock);
|
2007-05-06 21:50:24 +00:00
|
|
|
terminalDock->setObjectName("terminalDock");
|
|
|
|
terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
2009-01-14 20:14:36 +00:00
|
|
|
Panel* terminalPanel = new TerminalPanel(terminalDock);
|
2010-12-31 10:59:46 +00:00
|
|
|
terminalPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
|
2009-01-14 20:14:36 +00:00
|
|
|
terminalDock->setWidget(terminalPanel);
|
2007-05-06 21:50:24 +00:00
|
|
|
|
2009-01-14 20:14:36 +00:00
|
|
|
connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide()));
|
2007-12-19 01:35:09 +00:00
|
|
|
|
2010-05-03 17:46:34 +00:00
|
|
|
QAction* terminalAction = terminalDock->toggleViewAction();
|
2009-01-16 09:54:55 +00:00
|
|
|
terminalAction->setShortcut(Qt::Key_F4);
|
2009-05-26 18:39:25 +00:00
|
|
|
terminalAction->setIcon(KIcon("utilities-terminal"));
|
2010-12-19 12:48:24 +00:00
|
|
|
addActionCloneToCollection(terminalAction, "show_terminal_panel");
|
2007-05-06 21:50:24 +00:00
|
|
|
|
2007-07-25 17:32:37 +00:00
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
|
2007-05-06 21:50:24 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
2009-01-14 20:14:36 +00:00
|
|
|
terminalPanel, SLOT(setUrl(KUrl)));
|
2008-03-10 17:33:30 +00:00
|
|
|
#endif
|
2008-03-12 16:58:11 +00:00
|
|
|
|
2011-03-09 18:18:25 +00:00
|
|
|
// Setup "Search"
|
2010-10-27 17:17:20 +00:00
|
|
|
#ifdef HAVE_NEPOMUK
|
2011-03-09 18:18:25 +00:00
|
|
|
DolphinDockWidget* searchDock = new DolphinDockWidget(i18nc("@title:window", "Search"));
|
|
|
|
searchDock->setLocked(lock);
|
|
|
|
searchDock->setObjectName("searchDock");
|
|
|
|
searchDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
|
|
|
Panel* searchPanel = new SearchPanel(searchDock);
|
|
|
|
searchPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
|
|
|
|
connect(searchPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
|
|
|
|
searchDock->setWidget(searchPanel);
|
|
|
|
|
|
|
|
QAction* searchAction = searchDock->toggleViewAction();
|
|
|
|
searchAction->setShortcut(Qt::Key_F12);
|
|
|
|
searchAction->setIcon(KIcon("system-search"));
|
|
|
|
addActionCloneToCollection(searchAction, "show_search_panel");
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, searchDock);
|
2010-10-27 17:17:20 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
2011-03-09 18:18:25 +00:00
|
|
|
searchPanel, SLOT(setUrl(KUrl)));
|
2010-10-27 17:17:20 +00:00
|
|
|
#endif
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
|
|
|
|
if (firstRun) {
|
2010-06-16 21:13:41 +00:00
|
|
|
infoDock->hide();
|
2009-01-14 20:14:36 +00:00
|
|
|
foldersDock->hide();
|
2008-03-10 17:33:30 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2007-05-06 21:50:24 +00:00
|
|
|
terminalDock->hide();
|
2010-10-27 17:17:20 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NEPOMUK
|
2011-03-09 18:18:25 +00:00
|
|
|
searchDock->hide();
|
2008-03-12 16:58:11 +00:00
|
|
|
#endif
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-04-01 22:28:03 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Setup "Places"
|
|
|
|
DolphinDockWidget* placesDock = new DolphinDockWidget(i18nc("@title:window", "Places"));
|
|
|
|
placesDock->setLocked(lock);
|
2007-04-01 22:28:03 +00:00
|
|
|
placesDock->setObjectName("placesDock");
|
|
|
|
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
2008-01-30 22:22:46 +00:00
|
|
|
|
2009-01-14 20:14:36 +00:00
|
|
|
PlacesPanel* placesPanel = new PlacesPanel(placesDock);
|
2011-01-04 17:54:58 +00:00
|
|
|
QAction* separator = new QAction(placesPanel);
|
|
|
|
separator->setSeparator(true);
|
|
|
|
QList<QAction*> placesActions;
|
|
|
|
placesActions.append(separator);
|
|
|
|
placesActions.append(lockLayoutAction);
|
|
|
|
placesPanel->addActions(placesActions);
|
2009-01-14 20:14:36 +00:00
|
|
|
placesPanel->setModel(DolphinSettings::instance().placesModel());
|
|
|
|
placesPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
2010-12-31 10:59:46 +00:00
|
|
|
placesDock->setWidget(placesPanel);
|
2007-04-14 16:50:51 +00:00
|
|
|
|
2010-05-03 17:46:34 +00:00
|
|
|
QAction* placesAction = placesDock->toggleViewAction();
|
2009-01-16 09:54:55 +00:00
|
|
|
placesAction->setShortcut(Qt::Key_F9);
|
|
|
|
placesAction->setIcon(KIcon("bookmarks"));
|
2010-12-19 12:48:24 +00:00
|
|
|
addActionCloneToCollection(placesAction, "show_places_panel");
|
2007-04-14 16:50:51 +00:00
|
|
|
|
2007-04-01 22:28:03 +00:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
|
2009-01-14 20:14:36 +00:00
|
|
|
connect(placesPanel, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)),
|
2008-05-11 20:14:50 +00:00
|
|
|
this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
|
2007-04-02 08:51:57 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
2009-01-14 20:14:36 +00:00
|
|
|
placesPanel, SLOT(setUrl(KUrl)));
|
2011-03-26 15:37:13 +00:00
|
|
|
connect(placesDock, SIGNAL(visibilityChanged(bool)),
|
|
|
|
this, SLOT(slotPlacesPanelVisibilityChanged(bool)));
|
2010-05-03 15:40:24 +00:00
|
|
|
|
2010-12-31 10:59:46 +00:00
|
|
|
// Add actions into the "Panels" menu
|
2010-05-28 20:12:33 +00:00
|
|
|
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
|
2010-05-03 15:40:24 +00:00
|
|
|
actionCollection()->addAction("panels", panelsMenu);
|
|
|
|
panelsMenu->setDelayed(false);
|
|
|
|
panelsMenu->addAction(placesAction);
|
|
|
|
panelsMenu->addAction(infoAction);
|
|
|
|
panelsMenu->addAction(foldersAction);
|
2010-05-08 19:49:20 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2010-05-03 15:40:24 +00:00
|
|
|
panelsMenu->addAction(terminalAction);
|
2010-05-08 19:49:20 +00:00
|
|
|
#endif
|
2010-10-27 17:17:20 +00:00
|
|
|
#ifdef HAVE_NEPOMUK
|
2011-03-09 18:18:25 +00:00
|
|
|
panelsMenu->addAction(searchAction);
|
2010-10-27 17:17:20 +00:00
|
|
|
#endif
|
2010-12-31 10:59:46 +00:00
|
|
|
panelsMenu->addSeparator();
|
|
|
|
panelsMenu->addAction(lockLayoutAction);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateEditActions()
|
|
|
|
{
|
2007-10-02 19:03:03 +00:00
|
|
|
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
|
2007-04-01 18:36:23 +00:00
|
|
|
if (list.isEmpty()) {
|
|
|
|
stateChanged("has_no_selection");
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-04-01 18:36:23 +00:00
|
|
|
stateChanged("has_selection");
|
|
|
|
|
2008-06-01 18:44:35 +00:00
|
|
|
KActionCollection* col = actionCollection();
|
|
|
|
QAction* renameAction = col->action("rename");
|
|
|
|
QAction* moveToTrashAction = col->action("move_to_trash");
|
|
|
|
QAction* deleteAction = col->action("delete");
|
|
|
|
QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
|
2008-06-05 22:25:07 +00:00
|
|
|
QAction* deleteWithTrashShortcut = col->action("delete_shortcut"); // see DolphinViewActionHandler
|
2008-06-01 18:44:35 +00:00
|
|
|
|
2009-04-01 23:34:33 +00:00
|
|
|
KFileItemListProperties capabilities(list);
|
2008-04-18 20:31:31 +00:00
|
|
|
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
|
2008-06-01 18:44:35 +00:00
|
|
|
|
|
|
|
renameAction->setEnabled(capabilities.supportsMoving());
|
|
|
|
moveToTrashAction->setEnabled(enableMoveToTrash);
|
|
|
|
deleteAction->setEnabled(capabilities.supportsDeleting());
|
2008-06-05 22:25:07 +00:00
|
|
|
deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
|
2008-06-01 18:44:35 +00:00
|
|
|
cutAction->setEnabled(capabilities.supportsMoving());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
updatePasteAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateViewActions()
|
|
|
|
{
|
2008-02-11 12:34:48 +00:00
|
|
|
m_actionHandler->updateViewActions();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-01-28 11:37:08 +00:00
|
|
|
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
|
2007-06-07 21:10:48 +00:00
|
|
|
showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-08-12 17:48:29 +00:00
|
|
|
updateSplitAction();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-01-28 11:37:08 +00:00
|
|
|
QAction* editableLocactionAction = actionCollection()->action("editable_location");
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
|
|
|
editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateGoActions()
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
|
2010-09-21 19:38:26 +00:00
|
|
|
const KUrl currentUrl = m_activeViewContainer->url();
|
2007-04-01 18:36:23 +00:00
|
|
|
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
|
|
|
|
}
|
|
|
|
|
2009-03-01 01:38:20 +00:00
|
|
|
void DolphinMainWindow::rememberClosedTab(int index)
|
|
|
|
{
|
|
|
|
KMenu* tabsMenu = m_recentTabsMenu->menu();
|
|
|
|
|
|
|
|
const QString primaryPath = m_viewTab[index].primaryView->url().path();
|
|
|
|
const QString iconName = KMimeType::iconNameForUrl(primaryPath);
|
|
|
|
|
2009-07-10 06:07:32 +00:00
|
|
|
QAction* action = new QAction(squeezedText(primaryPath), tabsMenu);
|
2009-03-01 01:38:20 +00:00
|
|
|
|
|
|
|
ClosedTab closedTab;
|
|
|
|
closedTab.primaryUrl = m_viewTab[index].primaryView->url();
|
|
|
|
|
2011-02-09 18:21:58 +00:00
|
|
|
if (m_viewTab[index].secondaryView) {
|
2009-03-01 01:38:20 +00:00
|
|
|
closedTab.secondaryUrl = m_viewTab[index].secondaryView->url();
|
|
|
|
closedTab.isSplit = true;
|
|
|
|
} else {
|
|
|
|
closedTab.isSplit = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
action->setData(QVariant::fromValue(closedTab));
|
|
|
|
action->setIcon(KIcon(iconName));
|
|
|
|
|
2009-03-01 12:42:51 +00:00
|
|
|
// add the closed tab menu entry after the separator and
|
|
|
|
// "Empty Recently Closed Tabs" entry
|
2009-03-01 02:27:35 +00:00
|
|
|
if (tabsMenu->actions().size() == 2) {
|
2009-03-01 01:38:20 +00:00
|
|
|
tabsMenu->addAction(action);
|
|
|
|
} else {
|
2009-03-01 02:27:35 +00:00
|
|
|
tabsMenu->insertAction(tabsMenu->actions().at(2), action);
|
2009-03-01 01:38:20 +00:00
|
|
|
}
|
2009-03-10 06:36:34 +00:00
|
|
|
|
|
|
|
// assure that only up to 8 closed tabs are shown in the menu
|
2009-03-09 18:10:35 +00:00
|
|
|
if (tabsMenu->actions().size() > 8) {
|
|
|
|
tabsMenu->removeAction(tabsMenu->actions().last());
|
|
|
|
}
|
2009-03-01 01:38:20 +00:00
|
|
|
actionCollection()->action("closed_tabs")->setEnabled(true);
|
2009-03-09 19:50:32 +00:00
|
|
|
KAcceleratorManager::manage(tabsMenu);
|
2009-03-01 01:38:20 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::clearStatusBar()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->statusBar()->clear();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
connect(container, SIGNAL(showFilterBarChanged(bool)),
|
|
|
|
this, SLOT(updateFilterBarAction(bool)));
|
2010-01-25 07:58:24 +00:00
|
|
|
connect(container, SIGNAL(writeStateChanged(bool)),
|
|
|
|
this, SLOT(slotWriteStateChanged(bool)));
|
2010-10-27 17:08:02 +00:00
|
|
|
connect(container, SIGNAL(searchModeChanged(bool)),
|
|
|
|
this, SLOT(slotSearchModeChanged(bool)));
|
2007-06-07 21:10:48 +00:00
|
|
|
|
|
|
|
DolphinView* view = container->view();
|
2007-10-02 19:03:03 +00:00
|
|
|
connect(view, SIGNAL(selectionChanged(KFileItemList)),
|
|
|
|
this, SLOT(slotSelectionChanged(KFileItemList)));
|
2007-07-02 17:24:54 +00:00
|
|
|
connect(view, SIGNAL(requestItemInfo(KFileItem)),
|
|
|
|
this, SLOT(slotRequestItemInfo(KFileItem)));
|
2007-06-07 21:10:48 +00:00
|
|
|
connect(view, SIGNAL(activated()),
|
|
|
|
this, SLOT(toggleActiveView()));
|
2008-04-12 16:12:57 +00:00
|
|
|
connect(view, SIGNAL(tabRequested(const KUrl&)),
|
|
|
|
this, SLOT(openNewTab(const KUrl&)));
|
2010-01-25 07:58:24 +00:00
|
|
|
connect(view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)),
|
|
|
|
this, SLOT(openContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)));
|
2010-09-22 19:39:46 +00:00
|
|
|
connect(view, SIGNAL(startedPathLoading(KUrl)),
|
|
|
|
this, SLOT(enableStopAction()));
|
|
|
|
connect(view, SIGNAL(finishedPathLoading(KUrl)),
|
|
|
|
this, SLOT(disableStopAction()));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrlNavigator* navigator = container->urlNavigator();
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(navigator, SIGNAL(urlChanged(const KUrl&)),
|
|
|
|
this, SLOT(changeUrl(const KUrl&)));
|
|
|
|
connect(navigator, SIGNAL(historyChanged()),
|
2008-02-23 15:48:56 +00:00
|
|
|
this, SLOT(updateHistory()));
|
2008-02-07 07:27:06 +00:00
|
|
|
connect(navigator, SIGNAL(editableStateChanged(bool)),
|
|
|
|
this, SLOT(slotEditableStateChanged(bool)));
|
2010-01-25 09:00:51 +00:00
|
|
|
connect(navigator, SIGNAL(tabRequested(const KUrl&)),
|
|
|
|
this, SLOT(openNewTab(KUrl)));
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-04-12 17:37:53 +00:00
|
|
|
|
2007-08-12 17:48:29 +00:00
|
|
|
void DolphinMainWindow::updateSplitAction()
|
2007-06-03 14:07:45 +00:00
|
|
|
{
|
2007-06-03 15:50:52 +00:00
|
|
|
QAction* splitAction = actionCollection()->action("split_view");
|
2011-02-09 18:21:58 +00:00
|
|
|
if (m_viewTab[m_tabIndex].secondaryView) {
|
2008-07-22 17:36:52 +00:00
|
|
|
if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
|
2007-08-25 09:54:31 +00:00
|
|
|
splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
|
2009-11-06 18:02:55 +00:00
|
|
|
splitAction->setToolTip(i18nc("@info", "Close right view"));
|
2008-01-01 12:25:48 +00:00
|
|
|
splitAction->setIcon(KIcon("view-right-close"));
|
2007-08-12 17:48:29 +00:00
|
|
|
} else {
|
2007-08-25 09:54:31 +00:00
|
|
|
splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
|
2009-11-06 18:02:55 +00:00
|
|
|
splitAction->setToolTip(i18nc("@info", "Close left view"));
|
2008-01-01 12:25:48 +00:00
|
|
|
splitAction->setIcon(KIcon("view-left-close"));
|
2007-08-12 17:48:29 +00:00
|
|
|
}
|
2007-06-03 14:07:45 +00:00
|
|
|
} else {
|
2007-06-30 20:10:50 +00:00
|
|
|
splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
|
2009-11-06 18:02:55 +00:00
|
|
|
splitAction->setToolTip(i18nc("@info", "Split view"));
|
2008-01-01 12:25:48 +00:00
|
|
|
splitAction->setIcon(KIcon("view-right-new"));
|
2007-06-03 14:07:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-16 20:03:05 +00:00
|
|
|
QString DolphinMainWindow::tabName(const KUrl& url) const
|
|
|
|
{
|
2008-05-28 20:48:40 +00:00
|
|
|
QString name;
|
|
|
|
if (url.equals(KUrl("file:///"))) {
|
2009-05-19 07:25:40 +00:00
|
|
|
name = '/';
|
2008-05-28 20:48:40 +00:00
|
|
|
} else {
|
|
|
|
name = url.fileName();
|
|
|
|
if (name.isEmpty()) {
|
|
|
|
name = url.protocol();
|
2009-01-31 11:08:08 +00:00
|
|
|
} else {
|
|
|
|
// Make sure that a '&' inside the directory name is displayed correctly
|
|
|
|
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
|
|
|
|
name.replace('&', "&&");
|
2008-05-28 20:48:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return name;
|
2008-04-16 20:03:05 +00:00
|
|
|
}
|
|
|
|
|
2008-06-28 18:42:51 +00:00
|
|
|
bool DolphinMainWindow::isKompareInstalled() const
|
|
|
|
{
|
|
|
|
static bool initialized = false;
|
|
|
|
static bool installed = false;
|
|
|
|
if (!initialized) {
|
|
|
|
// TODO: maybe replace this approach later by using a menu
|
|
|
|
// plugin like kdiff3plugin.cpp
|
|
|
|
installed = !KGlobal::dirs()->findExe("kompare").isEmpty();
|
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
return installed;
|
|
|
|
}
|
|
|
|
|
2008-12-12 20:30:23 +00:00
|
|
|
void DolphinMainWindow::createSecondaryView(int tabIndex)
|
|
|
|
{
|
|
|
|
QSplitter* splitter = m_viewTab[tabIndex].splitter;
|
|
|
|
const int newWidth = (m_viewTab[tabIndex].primaryView->width() - splitter->handleWidth()) / 2;
|
|
|
|
|
|
|
|
const DolphinView* view = m_viewTab[tabIndex].primaryView->view();
|
2011-03-26 15:37:13 +00:00
|
|
|
m_viewTab[tabIndex].secondaryView = createViewContainer(view->rootUrl(), 0);
|
2008-12-12 20:30:23 +00:00
|
|
|
splitter->addWidget(m_viewTab[tabIndex].secondaryView);
|
|
|
|
splitter->setSizes(QList<int>() << newWidth << newWidth);
|
|
|
|
connectViewSignals(m_viewTab[tabIndex].secondaryView);
|
|
|
|
m_viewTab[tabIndex].secondaryView->setActive(false);
|
|
|
|
m_viewTab[tabIndex].secondaryView->show();
|
|
|
|
}
|
|
|
|
|
2009-03-19 07:23:41 +00:00
|
|
|
QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) const
|
|
|
|
{
|
|
|
|
return "Tab " + QString::number(tabIndex) + ' ' + property;
|
|
|
|
}
|
|
|
|
|
2009-05-05 21:49:03 +00:00
|
|
|
void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
|
|
|
|
{
|
2010-09-17 14:42:57 +00:00
|
|
|
QString caption;
|
|
|
|
if (!url.isLocalFile()) {
|
|
|
|
caption.append(url.protocol() + " - ");
|
|
|
|
if (url.hasHost()) {
|
|
|
|
caption.append(url.host() + " - ");
|
2010-01-20 11:26:39 +00:00
|
|
|
}
|
|
|
|
}
|
2010-09-17 14:42:57 +00:00
|
|
|
|
|
|
|
const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
|
|
|
|
caption.append(fileName);
|
|
|
|
|
|
|
|
setCaption(caption);
|
2009-05-05 21:49:03 +00:00
|
|
|
}
|
|
|
|
|
2009-07-10 06:07:32 +00:00
|
|
|
QString DolphinMainWindow::squeezedText(const QString& text) const
|
2009-07-09 04:41:53 +00:00
|
|
|
{
|
|
|
|
const QFontMetrics fm = fontMetrics();
|
2009-07-10 06:07:32 +00:00
|
|
|
return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10);
|
2009-07-09 04:41:53 +00:00
|
|
|
}
|
|
|
|
|
2010-12-19 12:48:24 +00:00
|
|
|
void DolphinMainWindow::addActionCloneToCollection(QAction* action, const QString& actionName)
|
|
|
|
{
|
|
|
|
KAction* actionClone = actionCollection()->addAction(actionName);
|
|
|
|
actionClone->setText(action->text());
|
|
|
|
actionClone->setIcon(action->icon());
|
|
|
|
connect(actionClone, SIGNAL(triggered()), action, SLOT(trigger()));
|
|
|
|
}
|
|
|
|
|
2008-04-20 22:07:44 +00:00
|
|
|
DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager::UiInterface()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
|
2007-04-12 17:37:53 +00:00
|
|
|
{
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
|
|
|
|
{
|
2008-04-20 22:07:44 +00:00
|
|
|
DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
|
|
|
|
if (mainWin) {
|
|
|
|
DolphinStatusBar* statusBar = mainWin->activeViewContainer()->statusBar();
|
|
|
|
statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
|
|
|
|
} else {
|
2008-04-30 23:32:33 +00:00
|
|
|
KIO::FileUndoManager::UiInterface::jobError(job);
|
2008-04-20 22:07:44 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "dolphinmainwindow.moc"
|