2007-04-01 18:36:23 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
|
|
|
|
* 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"
|
2008-02-11 12:34:48 +00:00
|
|
|
#include "dolphinviewactionhandler.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
|
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"
|
2008-01-30 22:22:46 +00:00
|
|
|
#include "dolphinfileplacesview.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
#include "dolphinnewmenu.h"
|
|
|
|
#include "dolphinsettings.h"
|
|
|
|
#include "dolphinsettingsdialog.h"
|
|
|
|
#include "dolphinstatusbar.h"
|
2007-06-07 21:10:48 +00:00
|
|
|
#include "dolphinviewcontainer.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
#include "infosidebarpage.h"
|
|
|
|
#include "metadatawidget.h"
|
|
|
|
#include "mainwindowadaptor.h"
|
|
|
|
#include "treeviewsidebarpage.h"
|
|
|
|
#include "viewproperties.h"
|
|
|
|
|
2008-03-10 17:33:30 +00:00
|
|
|
#ifndef Q_OS_WIN
|
|
|
|
#include "terminalsidebarpage.h"
|
|
|
|
#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"
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
#include <kaction.h>
|
|
|
|
#include <kactioncollection.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kdesktopfile.h>
|
|
|
|
#include <kdeversion.h>
|
|
|
|
#include <kfiledialog.h>
|
2008-01-30 22:22:46 +00:00
|
|
|
#include <kfileplacesmodel.h>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <kglobal.h>
|
|
|
|
#include <kicon.h>
|
|
|
|
#include <kiconloader.h>
|
|
|
|
#include <kio/netaccess.h>
|
|
|
|
#include <kinputdialog.h>
|
|
|
|
#include <klocale.h>
|
2008-10-07 22:05:55 +00:00
|
|
|
#include <kprotocolmanager.h>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <kmenu.h>
|
2007-11-18 14:37:57 +00:00
|
|
|
#include <kmenubar.h>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <kmessagebox.h>
|
2008-06-02 10:07:13 +00:00
|
|
|
#include <konq_fileitemcapabilities.h>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <konqmimedata.h>
|
|
|
|
#include <kprotocolinfo.h>
|
|
|
|
#include <krun.h>
|
|
|
|
#include <kshell.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <kstatusbar.h>
|
|
|
|
#include <kstandardaction.h>
|
2008-04-12 15:09:46 +00:00
|
|
|
#include <ktabbar.h>
|
2008-06-30 16:37:08 +00:00
|
|
|
#include <ktoggleaction.h>
|
|
|
|
#include <kurlnavigator.h>
|
2007-04-01 18:36:23 +00:00
|
|
|
#include <kurl.h>
|
2007-12-16 19:25:59 +00:00
|
|
|
#include <kurlcombobox.h>
|
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 <QLineEdit>
|
|
|
|
#include <QSplitter>
|
|
|
|
#include <QDockWidget>
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-09-28 18:38:00 +00:00
|
|
|
#include <kdebug.h>
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
DolphinMainWindow::DolphinMainWindow(int id) :
|
2007-05-06 17:41:49 +00:00
|
|
|
KXmlGuiWindow(0),
|
|
|
|
m_newMenu(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(),
|
2008-03-29 14:54:56 +00:00
|
|
|
m_actionHandler(0)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
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&)),
|
|
|
|
this, SLOT(slotHandlePlacesError(const QString&)));
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DolphinMainWindow::~DolphinMainWindow()
|
|
|
|
{
|
|
|
|
DolphinApplication::app()->removeMainWindow(this);
|
|
|
|
}
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
void DolphinMainWindow::toggleViews()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab[m_tabIndex].primaryView == 0) {
|
2007-04-01 18:36:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
// move secondary view from the last position of the splitter
|
|
|
|
// to the first position
|
2008-04-12 15:09:46 +00:00
|
|
|
m_viewTab[m_tabIndex].splitter->insertWidget(0, m_viewTab[m_tabIndex].secondaryView);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
DolphinViewContainer* container = m_viewTab[m_tabIndex].primaryView;
|
|
|
|
m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
|
|
|
|
m_viewTab[m_tabIndex].secondaryView = container;
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
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:
|
|
|
|
statusBar->setMessage(i18nc("@info:status", "Copy operation completed."),
|
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Move:
|
|
|
|
statusBar->setMessage(i18nc("@info:status", "Move operation completed."),
|
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Link:
|
|
|
|
statusBar->setMessage(i18nc("@info:status", "Link operation completed."),
|
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Trash:
|
|
|
|
statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."),
|
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KIO::FileUndoManager::Rename:
|
|
|
|
statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."),
|
|
|
|
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()
|
|
|
|
{
|
2008-04-12 15:09:46 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
|
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();
|
|
|
|
if (m_viewTab[i].secondaryView != 0) {
|
|
|
|
m_viewTab[i].secondaryView->refresh();
|
|
|
|
}
|
2007-06-12 21:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setActiveViewContainer(activeViewContainer);
|
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;
|
|
|
|
}
|
|
|
|
|
2007-06-13 17:08:39 +00:00
|
|
|
DolphinViewContainer* view = activeViewContainer();
|
|
|
|
if (view != 0) {
|
|
|
|
view->setUrl(url);
|
2007-04-01 18:36:23 +00:00
|
|
|
updateEditActions();
|
|
|
|
updateViewActions();
|
|
|
|
updateGoActions();
|
2008-04-16 20:03:05 +00:00
|
|
|
setCaption(url.fileName());
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab.count() > 1) {
|
2008-04-16 20:03:05 +00:00
|
|
|
m_tabBar->setTabText(m_tabIndex, tabName(url));
|
2008-04-12 15:09:46 +00:00
|
|
|
}
|
2007-10-20 17:05:16 +00:00
|
|
|
emit urlChanged(url);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-02 19:03:03 +00:00
|
|
|
void DolphinMainWindow::changeSelection(const KFileItemList& selection)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
activeViewContainer()->view()->changeSelection(selection);
|
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();
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
|
2008-07-26 13:49:50 +00:00
|
|
|
int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedItemsCount();
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab[m_tabIndex].secondaryView != 0) {
|
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
|
|
|
|
2008-07-26 13:49:50 +00:00
|
|
|
const bool activeViewHasSelection = (activeViewContainer()->view()->selectedItemsCount() > 0);
|
|
|
|
actionCollection()->action("quick_view")->setEnabled(activeViewHasSelection);
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->updateStatusBar();
|
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");
|
|
|
|
if (backAction != 0) {
|
|
|
|
backAction->setEnabled(index < urlNavigator->historySize() - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction* forwardAction = actionCollection()->action("go_forward");
|
|
|
|
if (forwardAction != 0) {
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
openNewTab(m_activeViewContainer->url());
|
|
|
|
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
|
|
|
}
|
|
|
|
|
2008-04-12 16:12:57 +00:00
|
|
|
void DolphinMainWindow::openNewTab(const KUrl& url)
|
|
|
|
{
|
|
|
|
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.
|
2008-04-16 20:03:05 +00:00
|
|
|
m_tabBar->addTab(KIcon("folder"), tabName(m_activeViewContainer->url()));
|
2008-04-13 20:20:30 +00:00
|
|
|
m_tabBar->blockSignals(false);
|
2008-04-12 16:12:57 +00:00
|
|
|
}
|
|
|
|
|
2008-04-16 20:03:05 +00:00
|
|
|
m_tabBar->addTab(KIcon("folder"), tabName(url));
|
2008-04-12 16:12:57 +00:00
|
|
|
|
|
|
|
ViewTab viewTab;
|
|
|
|
viewTab.splitter = new QSplitter(this);
|
|
|
|
viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
|
|
|
|
connectViewSignals(viewTab.primaryView);
|
|
|
|
viewTab.primaryView->view()->reload();
|
|
|
|
|
|
|
|
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-04-12 16:12:57 +00:00
|
|
|
}
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
void DolphinMainWindow::toggleActiveView()
|
|
|
|
{
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab[m_tabIndex].secondaryView == 0) {
|
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
|
|
|
|
|
|
|
Q_ASSERT(m_activeViewContainer != 0);
|
2008-04-12 15:09:46 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
|
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
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
|
|
|
DolphinSettings& settings = DolphinSettings::instance();
|
|
|
|
GeneralSettings* generalSettings = settings.generalSettings();
|
|
|
|
generalSettings->setFirstRun(false);
|
|
|
|
|
|
|
|
settings.save();
|
|
|
|
|
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
|
|
|
{
|
2008-04-12 15:09:46 +00:00
|
|
|
// TODO: remember tabs
|
|
|
|
DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
|
2007-11-30 18:42:17 +00:00
|
|
|
group.writeEntry("Primary Url", cont->url().url());
|
|
|
|
group.writeEntry("Primary Editable Url", cont->isUrlEditable());
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
cont = m_viewTab[m_tabIndex].secondaryView;
|
2007-11-30 18:42:17 +00:00
|
|
|
if (cont != 0) {
|
|
|
|
group.writeEntry("Secondary Url", cont->url().url());
|
|
|
|
group.writeEntry("Secondary Editable Url", cont->isUrlEditable());
|
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
|
|
|
{
|
2008-04-12 15:09:46 +00:00
|
|
|
// TODO: read tabs
|
|
|
|
DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
|
2007-11-30 18:42:17 +00:00
|
|
|
|
|
|
|
cont->setUrl(group.readEntry("Primary Url"));
|
|
|
|
bool editable = group.readEntry("Primary Editable Url", false);
|
|
|
|
cont->urlNavigator()->setUrlEditable(editable);
|
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
cont = m_viewTab[m_tabIndex].secondaryView;
|
2007-11-30 18:42:17 +00:00
|
|
|
const QString secondaryUrl = group.readEntry("Secondary Url");
|
|
|
|
if (!secondaryUrl.isEmpty()) {
|
|
|
|
if (cont == 0) {
|
|
|
|
// a secondary view should be shown, but no one is available
|
|
|
|
// currently -> create a new view
|
2007-04-01 18:36:23 +00:00
|
|
|
toggleSplitView();
|
2008-04-12 15:09:46 +00:00
|
|
|
cont = m_viewTab[m_tabIndex].secondaryView;
|
2007-11-30 18:42:17 +00:00
|
|
|
Q_ASSERT(cont != 0);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-11-30 18:42:17 +00:00
|
|
|
|
|
|
|
cont->setUrl(secondaryUrl);
|
|
|
|
bool editable = group.readEntry("Secondary Editable Url", false);
|
|
|
|
cont->urlNavigator()->setUrlEditable(editable);
|
|
|
|
} else if (cont != 0) {
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateNewMenu()
|
|
|
|
{
|
|
|
|
m_newMenu->slotCheckUpToDate();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_newMenu->setPopupFiles(activeViewContainer()->url());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::quit()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2007-06-15 00:52:25 +00:00
|
|
|
void DolphinMainWindow::slotHandlePlacesError(const QString &message)
|
|
|
|
{
|
|
|
|
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));
|
2007-04-01 18:36:23 +00:00
|
|
|
if (undoAction != 0) {
|
|
|
|
undoAction->setEnabled(available);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
|
|
|
|
{
|
2008-01-27 14:54:38 +00:00
|
|
|
QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
|
2007-04-01 18:36:23 +00:00
|
|
|
if (undoAction != 0) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
QLineEdit* lineEdit = urlNavigator->editor()->lineEdit();
|
|
|
|
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()
|
|
|
|
{
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab[m_tabIndex].secondaryView == 0) {
|
2007-04-01 18:36:23 +00:00
|
|
|
// create a secondary view
|
2008-04-12 15:09:46 +00:00
|
|
|
QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
|
|
|
|
const int newWidth = (m_viewTab[m_tabIndex].primaryView->width() - splitter->handleWidth()) / 2;
|
|
|
|
|
|
|
|
const DolphinView* view = m_viewTab[m_tabIndex].primaryView->view();
|
|
|
|
m_viewTab[m_tabIndex].secondaryView = new DolphinViewContainer(this, 0, view->rootUrl());
|
|
|
|
connectViewSignals(m_viewTab[m_tabIndex].secondaryView);
|
|
|
|
splitter->addWidget(m_viewTab[m_tabIndex].secondaryView);
|
|
|
|
splitter->setSizes(QList<int>() << newWidth << newWidth);
|
|
|
|
m_viewTab[m_tabIndex].secondaryView->view()->reload();
|
|
|
|
m_viewTab[m_tabIndex].secondaryView->setActive(false);
|
|
|
|
m_viewTab[m_tabIndex].secondaryView->show();
|
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
|
|
|
{
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-01-28 11:37:08 +00:00
|
|
|
void DolphinMainWindow::toggleFilterBarVisibility(bool show)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->showFilterBar(show);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::editLocation()
|
|
|
|
{
|
2007-11-04 18:50:22 +00:00
|
|
|
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
|
|
|
|
navigator->setUrlEditable(true);
|
|
|
|
navigator->setFocus();
|
2008-02-16 22:05:34 +00:00
|
|
|
|
|
|
|
// select the whole text of the combo box editor
|
|
|
|
QLineEdit* lineEdit = navigator->editor()->lineEdit();
|
|
|
|
const QString text = lineEdit->text();
|
|
|
|
lineEdit->setSelection(0, text.length());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::goBack()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->urlNavigator()->goBack();
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2008-04-12 15:09:46 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KUrl urlA;
|
|
|
|
KUrl urlB;
|
2008-04-12 15:09:46 +00:00
|
|
|
KUrl::List urls = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
switch (urls.count()) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case 0: {
|
2008-04-12 15:09:46 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
|
|
|
|
urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
|
2007-04-09 19:12:54 +00:00
|
|
|
Q_ASSERT(urls.count() == 2);
|
|
|
|
urlA = urls[0];
|
|
|
|
urlB = urls[1];
|
|
|
|
break;
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
case 1: {
|
|
|
|
urlA = urls[0];
|
2008-04-12 15:09:46 +00:00
|
|
|
Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
|
|
|
|
urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
|
2007-04-09 19:12:54 +00:00
|
|
|
Q_ASSERT(urls.count() == 1);
|
|
|
|
urlB = urls[0];
|
|
|
|
break;
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
case 2: {
|
|
|
|
urlA = urls[0];
|
|
|
|
urlB = urls[1];
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-07-26 13:49:50 +00:00
|
|
|
void DolphinMainWindow::quickView()
|
|
|
|
{
|
|
|
|
const KUrl::List urls = activeViewContainer()->view()->selectedUrls();
|
|
|
|
Q_ASSERT(urls.count() > 0);
|
|
|
|
|
2008-07-26 19:09:17 +00:00
|
|
|
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.plasma", "/Previewer", "", "openFile");
|
2008-07-26 13:49:50 +00:00
|
|
|
foreach (const KUrl& url, urls) {
|
2008-07-26 19:09:17 +00:00
|
|
|
msg.setArguments(QList<QVariant>() << url.prettyUrl());
|
|
|
|
QDBusConnection::sessionBus().send(msg);
|
2008-07-26 13:49:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-18 14:37:57 +00:00
|
|
|
void DolphinMainWindow::toggleShowMenuBar()
|
|
|
|
{
|
|
|
|
const bool visible = menuBar()->isVisible();
|
|
|
|
menuBar()->setVisible(!visible);
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::editSettings()
|
|
|
|
{
|
2007-05-05 21:02:04 +00:00
|
|
|
DolphinSettingsDialog dialog(this);
|
|
|
|
dialog.exec();
|
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-04-13 19:12:52 +00:00
|
|
|
m_viewTab[m_tabIndex].isPrimaryViewActive = m_viewTab[m_tabIndex].primaryView->isActive();
|
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];
|
|
|
|
m_centralWidgetLayout->addWidget(viewTab.splitter);
|
|
|
|
viewTab.primaryView->show();
|
|
|
|
if (viewTab.secondaryView != 0) {
|
|
|
|
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) {
|
|
|
|
// the last tab may never get closed
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// delete tab
|
|
|
|
m_viewTab[index].primaryView->deleteLater();
|
|
|
|
if (m_viewTab[index].secondaryView != 0) {
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
KMenu menu(this);
|
|
|
|
|
|
|
|
QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
|
|
|
|
newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
|
|
|
|
|
2008-05-18 15:31:24 +00:00
|
|
|
QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
|
2008-04-16 20:03:05 +00:00
|
|
|
|
|
|
|
QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
|
|
|
|
closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
|
|
|
|
|
|
|
|
QAction* selectedAction = menu.exec(pos);
|
|
|
|
if (selectedAction == newTabAction) {
|
|
|
|
const ViewTab& tab = m_viewTab[index];
|
2008-04-16 21:27:39 +00:00
|
|
|
Q_ASSERT(tab.primaryView != 0);
|
|
|
|
const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ?
|
|
|
|
tab.secondaryView->url() : tab.primaryView->url();
|
2008-04-16 20:03:05 +00:00
|
|
|
openNewTab(url);
|
|
|
|
m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
|
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
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);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
setupActions();
|
|
|
|
|
2008-02-14 21:25:36 +00:00
|
|
|
const KUrl& homeUrl = generalSettings->homeUrl();
|
2007-04-01 18:36:23 +00:00
|
|
|
setCaption(homeUrl.fileName());
|
2008-02-11 12:34:48 +00:00
|
|
|
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
|
|
|
|
connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
|
2007-04-01 18:36:23 +00:00
|
|
|
ViewProperties props(homeUrl);
|
2008-04-12 15:09:46 +00:00
|
|
|
m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this,
|
|
|
|
m_viewTab[m_tabIndex].splitter,
|
|
|
|
homeUrl);
|
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();
|
2008-02-11 12:34:48 +00:00
|
|
|
view->reload();
|
2008-04-12 15:09:46 +00:00
|
|
|
m_activeViewContainer->show();
|
2008-02-11 12:34:48 +00:00
|
|
|
m_actionHandler->setCurrentView(view);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2008-04-12 15:09:46 +00:00
|
|
|
m_tabBar = new KTabBar(this);
|
2008-04-14 20:19:17 +00:00
|
|
|
m_tabBar->setCloseButtonEnabled(true);
|
2008-04-12 15:09:46 +00:00
|
|
|
connect(m_tabBar, SIGNAL(currentChanged(int)),
|
|
|
|
this, SLOT(setActiveTab(int)));
|
2008-04-13 20:20:30 +00:00
|
|
|
connect(m_tabBar, SIGNAL(closeRequest(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&)));
|
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);
|
|
|
|
m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter);
|
|
|
|
|
|
|
|
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()));
|
|
|
|
updatePasteAction();
|
|
|
|
updateGoActions();
|
|
|
|
|
2007-08-12 17:48:29 +00:00
|
|
|
if (generalSettings->splitView()) {
|
2007-06-20 15:46:57 +00:00
|
|
|
toggleSplitView();
|
|
|
|
}
|
|
|
|
updateViewActions();
|
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
|
|
|
{
|
2008-02-11 12:34:48 +00:00
|
|
|
Q_ASSERT(viewContainer != 0);
|
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();
|
|
|
|
|
2007-06-13 17:08:39 +00:00
|
|
|
const KUrl& url = m_activeViewContainer->url();
|
2008-04-16 20:03:05 +00:00
|
|
|
setCaption(url.fileName());
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab.count() > 1) {
|
2008-04-16 20:03:05 +00:00
|
|
|
m_tabBar->setTabText(m_tabIndex, tabName(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
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::setupActions()
|
|
|
|
{
|
|
|
|
// setup 'File' menu
|
|
|
|
m_newMenu = new DolphinNewMenu(this);
|
|
|
|
KMenu* menu = m_newMenu->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"));
|
2008-06-29 13:36:53 +00:00
|
|
|
newTab->setShortcut(KShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_N, Qt::CTRL | Qt::Key_T));
|
2008-04-12 15:09:46 +00:00
|
|
|
connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
|
|
|
|
|
2008-04-16 20:03:05 +00:00
|
|
|
QAction* closeTab = new QAction(KIcon("tab-close"), i18nc("@action:inmenu File", "Close Tab"), this);
|
|
|
|
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()));
|
|
|
|
actionCollection()->addAction("close_tab", 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();
|
|
|
|
cutShortcut.remove(Qt::SHIFT + Qt::Key_Delete, KShortcut::KeepEmpty);
|
|
|
|
cut->setShortcut(cutShortcut);
|
2007-04-01 18:36:23 +00:00
|
|
|
KStandardAction::copy(this, SLOT(copy()), actionCollection());
|
|
|
|
KStandardAction::paste(this, SLOT(paste()), 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"));
|
2007-04-01 18:36:23 +00:00
|
|
|
selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
|
|
|
|
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"));
|
2007-04-01 18:36:23 +00:00
|
|
|
stop->setIcon(KIcon("process-stop"));
|
|
|
|
connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
|
|
|
|
|
2008-02-07 07:27:06 +00:00
|
|
|
// TODO: the naming "Show full Location" is currently confusing...
|
2007-04-01 18:36:23 +00:00
|
|
|
KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
|
2007-06-30 20:10:50 +00:00
|
|
|
showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Show Full Location"));
|
2007-04-01 18:36:23 +00:00
|
|
|
showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
|
|
|
|
connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
|
|
|
|
|
2007-10-29 11:03:37 +00:00
|
|
|
KAction* editLocation = actionCollection()->addAction("edit_location");
|
2007-06-30 20:10:50 +00:00
|
|
|
editLocation->setText(i18nc("@action:inmenu Navigation Bar", "Edit Location"));
|
2007-04-01 18:36:23 +00:00
|
|
|
editLocation->setShortcut(Qt::Key_F6);
|
|
|
|
connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
|
|
|
|
|
|
|
|
// setup 'Go' menu
|
2007-09-09 19:02:22 +00:00
|
|
|
KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
|
|
|
|
KShortcut backShortcut = backAction->shortcut();
|
|
|
|
backShortcut.setAlternate(Qt::Key_Backspace);
|
|
|
|
backAction->setShortcut(backShortcut);
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
KStandardAction::forward(this, SLOT(goForward()), actionCollection());
|
|
|
|
KStandardAction::up(this, SLOT(goUp()), actionCollection());
|
|
|
|
KStandardAction::home(this, SLOT(goHome()), actionCollection());
|
|
|
|
|
|
|
|
// setup 'Tools' menu
|
|
|
|
KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
|
2007-06-30 20:10:50 +00:00
|
|
|
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
|
2007-05-07 05:33:20 +00:00
|
|
|
showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
|
2008-01-28 11:37:08 +00:00
|
|
|
connect(showFilterBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
|
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()));
|
|
|
|
|
2008-07-26 13:49:50 +00:00
|
|
|
KAction* quickView = actionCollection()->addAction("quick_view");
|
|
|
|
quickView->setText(i18nc("@action:inmenu Tools", "Quick View"));
|
|
|
|
quickView->setIcon(KIcon("view-preview"));
|
2008-09-04 20:11:14 +00:00
|
|
|
quickView->setShortcut(Qt::CTRL + Qt::Key_Return);
|
2008-07-26 13:49:50 +00:00
|
|
|
quickView->setEnabled(false);
|
|
|
|
connect(quickView, SIGNAL(triggered()), this, SLOT(quickView()));
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
// setup 'Settings' menu
|
2007-11-18 14:37:57 +00:00
|
|
|
m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
|
2007-04-01 18:36:23 +00:00
|
|
|
KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::setupDockWidgets()
|
|
|
|
{
|
|
|
|
// setup "Information"
|
2007-06-30 20:10:50 +00:00
|
|
|
QDockWidget* infoDock = new QDockWidget(i18nc("@title:window", "Information"));
|
2007-04-01 18:36:23 +00:00
|
|
|
infoDock->setObjectName("infoDock");
|
|
|
|
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
|
|
|
SidebarPage* infoWidget = new InfoSidebarPage(infoDock);
|
|
|
|
infoDock->setWidget(infoWidget);
|
|
|
|
|
2007-06-30 20:10:50 +00:00
|
|
|
infoDock->toggleViewAction()->setText(i18nc("@title:window", "Information"));
|
2007-09-09 12:54:24 +00:00
|
|
|
infoDock->toggleViewAction()->setShortcut(Qt::Key_F11);
|
2007-04-01 18:36:23 +00:00
|
|
|
actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
|
|
|
|
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, infoDock);
|
2007-05-02 05:15:03 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
|
|
|
infoWidget, SLOT(setUrl(KUrl)));
|
2007-10-02 19:03:03 +00:00
|
|
|
connect(this, SIGNAL(selectionChanged(KFileItemList)),
|
|
|
|
infoWidget, SLOT(setSelection(KFileItemList)));
|
2007-07-02 17:24:54 +00:00
|
|
|
connect(this, SIGNAL(requestItemInfo(KFileItem)),
|
|
|
|
infoWidget, SLOT(requestDelayedItemInfo(KFileItem)));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
// setup "Tree View"
|
2007-06-30 20:10:50 +00:00
|
|
|
QDockWidget* treeViewDock = new QDockWidget(i18nc("@title:window", "Folders"));
|
2007-04-01 18:36:23 +00:00
|
|
|
treeViewDock->setObjectName("treeViewDock");
|
|
|
|
treeViewDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
|
|
|
TreeViewSidebarPage* treeWidget = new TreeViewSidebarPage(treeViewDock);
|
|
|
|
treeViewDock->setWidget(treeWidget);
|
|
|
|
|
2007-06-30 20:10:50 +00:00
|
|
|
treeViewDock->toggleViewAction()->setText(i18nc("@title:window", "Folders"));
|
2007-08-30 06:20:24 +00:00
|
|
|
treeViewDock->toggleViewAction()->setShortcut(Qt::Key_F7);
|
2007-04-01 18:36:23 +00:00
|
|
|
actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction());
|
|
|
|
|
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, treeViewDock);
|
2007-05-02 05:15:03 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
|
|
|
treeWidget, SLOT(setUrl(KUrl)));
|
2008-05-11 21:51:04 +00:00
|
|
|
connect(treeWidget, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)),
|
|
|
|
this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
|
2007-10-02 19:03:03 +00:00
|
|
|
connect(treeWidget, SIGNAL(changeSelection(KFileItemList)),
|
|
|
|
this, SLOT(changeSelection(KFileItemList)));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-05-06 21:50:24 +00:00
|
|
|
// setup "Terminal"
|
2008-03-10 17:33:30 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2008-03-18 22:38:52 +00:00
|
|
|
QDockWidget* terminalDock = new QDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
|
2007-05-06 21:50:24 +00:00
|
|
|
terminalDock->setObjectName("terminalDock");
|
|
|
|
terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
|
|
|
SidebarPage* terminalWidget = new TerminalSidebarPage(terminalDock);
|
|
|
|
terminalDock->setWidget(terminalWidget);
|
|
|
|
|
2007-12-19 01:35:09 +00:00
|
|
|
connect(terminalWidget, SIGNAL(hideTerminalSidebarPage()), terminalDock, SLOT(hide()));
|
|
|
|
|
2008-03-18 22:38:52 +00:00
|
|
|
terminalDock->toggleViewAction()->setText(i18nc("@title:window Shell terminal", "Terminal"));
|
2007-07-13 18:25:36 +00:00
|
|
|
terminalDock->toggleViewAction()->setShortcut(Qt::Key_F4);
|
2007-05-06 21:50:24 +00:00
|
|
|
actionCollection()->addAction("show_terminal_panel", terminalDock->toggleViewAction());
|
|
|
|
|
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)),
|
|
|
|
terminalWidget, SLOT(setUrl(KUrl)));
|
2008-03-10 17:33:30 +00:00
|
|
|
#endif
|
2008-03-12 16:58:11 +00:00
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
|
|
|
|
if (firstRun) {
|
|
|
|
treeViewDock->hide();
|
2008-03-10 17:33:30 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2007-05-06 21:50:24 +00:00
|
|
|
terminalDock->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
|
|
|
|
2007-10-24 20:28:28 +00:00
|
|
|
QDockWidget* placesDock = new QDockWidget(i18nc("@title:window", "Places"));
|
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
|
|
|
|
|
|
|
DolphinFilePlacesView* placesView = new DolphinFilePlacesView(placesDock);
|
2007-10-24 20:28:28 +00:00
|
|
|
placesDock->setWidget(placesView);
|
|
|
|
placesView->setModel(DolphinSettings::instance().placesModel());
|
|
|
|
placesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
2007-04-14 16:50:51 +00:00
|
|
|
|
2007-06-30 20:10:50 +00:00
|
|
|
placesDock->toggleViewAction()->setText(i18nc("@title:window", "Places"));
|
2007-08-30 06:20:24 +00:00
|
|
|
placesDock->toggleViewAction()->setShortcut(Qt::Key_F9);
|
2007-04-14 16:50:51 +00:00
|
|
|
actionCollection()->addAction("show_places_panel", placesDock->toggleViewAction());
|
|
|
|
|
2007-04-01 22:28:03 +00:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
|
2008-05-11 20:14:50 +00:00
|
|
|
connect(placesView, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)),
|
|
|
|
this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
|
2007-04-02 08:51:57 +00:00
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
2007-10-24 20:28:28 +00:00
|
|
|
placesView, SLOT(setUrl(KUrl)));
|
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
|
|
|
|
2008-06-02 10:07:13 +00:00
|
|
|
KonqFileItemCapabilities 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));
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl& currentUrl = m_activeViewContainer->url();
|
2007-04-01 18:36:23 +00:00
|
|
|
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
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&)));
|
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)));
|
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");
|
2008-04-12 15:09:46 +00:00
|
|
|
if (m_viewTab[m_tabIndex].secondaryView != 0) {
|
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"));
|
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"));
|
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"));
|
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:///"))) {
|
|
|
|
name = "/";
|
|
|
|
} else {
|
|
|
|
name = url.fileName();
|
|
|
|
if (name.isEmpty()) {
|
|
|
|
name = url.protocol();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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-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"
|