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"
|
|
|
|
|
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"
|
|
|
|
#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"
|
2007-05-06 21:50:24 +00:00
|
|
|
#include "terminalsidebarpage.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
#include "treeviewsidebarpage.h"
|
2007-04-02 19:20:07 +00:00
|
|
|
#include "kurlnavigator.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
#include "viewpropertiesdialog.h"
|
|
|
|
#include "viewproperties.h"
|
2007-04-01 22:28:03 +00:00
|
|
|
#include "kfileplacesmodel.h"
|
2007-04-02 08:51:57 +00:00
|
|
|
#include "kfileplacesview.h"
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
#include "dolphin_generalsettings.h"
|
|
|
|
|
|
|
|
#include <kaction.h>
|
|
|
|
#include <kactioncollection.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kdesktopfile.h>
|
|
|
|
#include <kdeversion.h>
|
|
|
|
#include <kfiledialog.h>
|
|
|
|
#include <kglobal.h>
|
|
|
|
#include <kicon.h>
|
|
|
|
#include <kiconloader.h>
|
|
|
|
#include <kio/netaccess.h>
|
|
|
|
#include <kio/deletejob.h>
|
|
|
|
#include <kio/renamedialog.h>
|
|
|
|
#include <kinputdialog.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kmenu.h>
|
|
|
|
#include <kmessagebox.h>
|
|
|
|
#include <konqmimedata.h>
|
|
|
|
#include <konq_operations.h>
|
|
|
|
#include <kpropertiesdialog.h>
|
|
|
|
#include <kprotocolinfo.h>
|
|
|
|
#include <ktoggleaction.h>
|
|
|
|
#include <krun.h>
|
|
|
|
#include <kshell.h>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
#include <kstatusbar.h>
|
|
|
|
#include <kstandardaction.h>
|
|
|
|
#include <kurl.h>
|
|
|
|
|
2007-05-09 22:23:52 +00:00
|
|
|
#include <QtGui/QKeyEvent>
|
|
|
|
#include <QtGui/QClipboard>
|
|
|
|
#include <QtGui/QSplitter>
|
|
|
|
#include <QtGui/QDockWidget>
|
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),
|
|
|
|
m_splitter(0),
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer(0),
|
2007-05-06 17:41:49 +00:00
|
|
|
m_id(id)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
setObjectName("Dolphin");
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[PrimaryView] = 0;
|
|
|
|
m_viewContainer[SecondaryView] = 0;
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
new MainWindowAdaptor(this);
|
|
|
|
QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);
|
|
|
|
|
|
|
|
KonqUndoManager::incRef();
|
|
|
|
|
|
|
|
KonqUndoManager* undoManager = KonqUndoManager::self();
|
|
|
|
undoManager->setUiInterface(new UndoUiInterface(this));
|
|
|
|
|
|
|
|
connect(undoManager, SIGNAL(undoAvailable(bool)),
|
|
|
|
this, SLOT(slotUndoAvailable(bool)));
|
|
|
|
connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
|
|
|
|
this, SLOT(slotUndoTextChanged(const QString&)));
|
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()
|
|
|
|
{
|
|
|
|
KonqUndoManager::decRef();
|
|
|
|
DolphinApplication::app()->removeMainWindow(this);
|
|
|
|
}
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
void DolphinMainWindow::toggleViews()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
2007-06-12 21:45:22 +00:00
|
|
|
if (m_viewContainer[SecondaryView] == 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
|
|
|
|
m_splitter->insertWidget(0, m_viewContainer[SecondaryView]);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
DolphinViewContainer* container = m_viewContainer[PrimaryView];
|
|
|
|
m_viewContainer[PrimaryView] = m_viewContainer[SecondaryView];
|
|
|
|
m_viewContainer[SecondaryView] = container;
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
void DolphinMainWindow::rename(const KUrl& oldUrl, const KUrl& newUrl)
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
KonqOperations::rename(this, oldUrl, newUrl);
|
|
|
|
m_undoCommandTypes.append(KonqUndoManager::RENAME);
|
|
|
|
}
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
void DolphinMainWindow::refreshViews()
|
|
|
|
{
|
|
|
|
Q_ASSERT(m_viewContainer[PrimaryView] != 0);
|
|
|
|
|
|
|
|
// remember the current active view, as because of
|
|
|
|
// the refreshing the active view might change to
|
|
|
|
// the secondary view
|
|
|
|
DolphinViewContainer* activeViewContainer = m_activeViewContainer;
|
|
|
|
|
|
|
|
m_viewContainer[PrimaryView]->view()->refresh();
|
|
|
|
if (m_viewContainer[SecondaryView] != 0) {
|
|
|
|
m_viewContainer[SecondaryView]->view()->refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
setActiveViewContainer(activeViewContainer);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::dropUrls(const KUrl::List& urls,
|
|
|
|
const KUrl& destination)
|
|
|
|
{
|
|
|
|
Qt::DropAction action = Qt::CopyAction;
|
|
|
|
|
|
|
|
Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
|
|
|
|
const bool shiftPressed = modifier & Qt::ShiftModifier;
|
|
|
|
const bool controlPressed = modifier & Qt::ControlModifier;
|
|
|
|
if (shiftPressed && controlPressed) {
|
|
|
|
// shortcut for 'Link Here' is used
|
|
|
|
action = Qt::LinkAction;
|
2007-04-09 19:12:54 +00:00
|
|
|
} else if (shiftPressed) {
|
2007-04-01 18:36:23 +00:00
|
|
|
// shortcut for 'Move Here' is used
|
|
|
|
action = Qt::MoveAction;
|
2007-04-09 19:12:54 +00:00
|
|
|
} else if (controlPressed) {
|
2007-04-01 18:36:23 +00:00
|
|
|
// shortcut for 'Copy Here' is used
|
|
|
|
action = Qt::CopyAction;
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-04-01 18:36:23 +00:00
|
|
|
// open a context menu which offers the following actions:
|
|
|
|
// - Move Here
|
|
|
|
// - Copy Here
|
|
|
|
// - Link Here
|
|
|
|
// - Cancel
|
|
|
|
|
|
|
|
KMenu popup(this);
|
|
|
|
|
|
|
|
QString seq = QKeySequence(Qt::ShiftModifier).toString();
|
|
|
|
seq.chop(1); // chop superfluous '+'
|
|
|
|
QAction* moveAction = popup.addAction(KIcon("goto-page"),
|
2007-07-08 21:09:48 +00:00
|
|
|
i18nc("@action:inmenu",
|
|
|
|
"&Move Here\t<shortcut>%1</shortcut>", seq));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
seq = QKeySequence(Qt::ControlModifier).toString();
|
|
|
|
seq.chop(1);
|
|
|
|
QAction* copyAction = popup.addAction(KIcon("edit-copy"),
|
2007-07-08 21:09:48 +00:00
|
|
|
i18nc("@action:inmenu",
|
|
|
|
"&Copy Here\t<shortcut>%1</shortcut>", seq));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString();
|
|
|
|
seq.chop(1);
|
|
|
|
QAction* linkAction = popup.addAction(KIcon("www"),
|
2007-07-08 21:09:48 +00:00
|
|
|
i18nc("@action:inmenu",
|
|
|
|
"&Link Here\t<shortcut>%1</shortcut>", seq));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
popup.addSeparator();
|
2007-06-30 20:10:50 +00:00
|
|
|
popup.addAction(KIcon("process-stop"), i18nc("@action:inmenu", "Cancel"));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
QAction* activatedAction = popup.exec(QCursor::pos());
|
|
|
|
if (activatedAction == moveAction) {
|
|
|
|
action = Qt::MoveAction;
|
2007-04-09 19:12:54 +00:00
|
|
|
} else if (activatedAction == copyAction) {
|
2007-04-01 18:36:23 +00:00
|
|
|
action = Qt::CopyAction;
|
2007-04-09 19:12:54 +00:00
|
|
|
} else if (activatedAction == linkAction) {
|
2007-04-01 18:36:23 +00:00
|
|
|
action = Qt::LinkAction;
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-04-01 18:36:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (action) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case Qt::MoveAction:
|
|
|
|
moveUrls(urls, destination);
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
case Qt::CopyAction:
|
|
|
|
copyUrls(urls, destination);
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
case Qt::LinkAction:
|
|
|
|
linkUrls(urls, destination);
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::changeUrl(const KUrl& url)
|
|
|
|
{
|
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();
|
|
|
|
setCaption(url.fileName());
|
|
|
|
emit urlChanged(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-13 21:57:20 +00:00
|
|
|
void DolphinMainWindow::changeSelection(const QList<KFileItem>& 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
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotViewModeChanged()
|
|
|
|
{
|
|
|
|
updateViewActions();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotShowPreviewChanged()
|
|
|
|
{
|
|
|
|
// It is not enough to update the 'Show Preview' action, also
|
|
|
|
// the 'Zoom In' and 'Zoom Out' actions must be adapted.
|
|
|
|
updateViewActions();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotShowHiddenFilesChanged()
|
|
|
|
{
|
|
|
|
KToggleAction* showHiddenFilesAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
|
2007-06-07 21:10:48 +00:00
|
|
|
const DolphinView* view = m_activeViewContainer->view();
|
|
|
|
showHiddenFilesAction->setChecked(view->showHiddenFiles());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-04-10 11:22:56 +00:00
|
|
|
void DolphinMainWindow::slotCategorizedSortingChanged()
|
|
|
|
{
|
2007-06-19 16:00:21 +00:00
|
|
|
KToggleAction* showInGroupsAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_in_groups"));
|
2007-06-07 21:10:48 +00:00
|
|
|
const DolphinView* view = m_activeViewContainer->view();
|
2007-06-19 16:00:21 +00:00
|
|
|
showInGroupsAction->setChecked(view->categorizedSorting());
|
|
|
|
showInGroupsAction->setEnabled(view->supportsCategorizedSorting());
|
2007-04-10 11:22:56 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
|
|
|
|
{
|
|
|
|
QAction* action = 0;
|
|
|
|
switch (sorting) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case DolphinView::SortByName:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_name");
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
case DolphinView::SortBySize:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_size");
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
case DolphinView::SortByDate:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_date");
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
case DolphinView::SortByPermissions:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_permissions");
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
case DolphinView::SortByOwner:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_owner");
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
|
|
|
case DolphinView::SortByGroup:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_group");
|
2007-04-09 19:12:54 +00:00
|
|
|
break;
|
2007-04-22 21:04:46 +00:00
|
|
|
case DolphinView::SortByType:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_type");
|
2007-06-22 10:18:46 +00:00
|
|
|
break;
|
|
|
|
#ifdef HAVE_NEPOMUK
|
|
|
|
case DolphinView::SortByRating:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_rating");
|
2007-06-22 10:18:46 +00:00
|
|
|
break;
|
|
|
|
case DolphinView::SortByTags:
|
2007-07-13 18:14:41 +00:00
|
|
|
action = actionCollection()->action("sort_by_tags");
|
2007-06-22 10:18:46 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2007-04-09 19:12:54 +00:00
|
|
|
default:
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action != 0) {
|
|
|
|
KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
|
|
|
|
toggleAction->setChecked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
|
|
|
|
{
|
|
|
|
KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
|
2007-04-04 13:02:52 +00:00
|
|
|
const bool sortDescending = (order == Qt::DescendingOrder);
|
2007-04-01 18:36:23 +00:00
|
|
|
descending->setChecked(sortDescending);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info)
|
|
|
|
{
|
|
|
|
QAction* action = 0;
|
|
|
|
switch (info) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case KFileItemDelegate::FriendlyMimeType:
|
|
|
|
action = actionCollection()->action("show_mime_info");
|
|
|
|
break;
|
|
|
|
case KFileItemDelegate::Size:
|
|
|
|
action = actionCollection()->action("show_size_info");
|
|
|
|
break;
|
|
|
|
case KFileItemDelegate::ModificationTime:
|
|
|
|
action = actionCollection()->action("show_date_info");
|
|
|
|
break;
|
|
|
|
case KFileItemDelegate::NoInformation:
|
|
|
|
default:
|
|
|
|
action = actionCollection()->action("clear_info");
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action != 0) {
|
|
|
|
KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
|
|
|
|
toggleAction->setChecked(true);
|
|
|
|
|
|
|
|
QActionGroup* group = toggleAction->actionGroup();
|
|
|
|
Q_ASSERT(group != 0);
|
2007-06-07 21:10:48 +00:00
|
|
|
const DolphinView* view = m_activeViewContainer->view();
|
|
|
|
group->setEnabled(view->mode() == DolphinView::IconsView);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-13 21:57:20 +00:00
|
|
|
void DolphinMainWindow::slotSelectionChanged(const QList<KFileItem>& selection)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
updateEditActions();
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
Q_ASSERT(m_viewContainer[PrimaryView] != 0);
|
|
|
|
int selectedUrlsCount = m_viewContainer[PrimaryView]->view()->selectedUrls().count();
|
|
|
|
if (m_viewContainer[SecondaryView] != 0) {
|
|
|
|
selectedUrlsCount += m_viewContainer[SecondaryView]->view()->selectedUrls().count();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QAction* compareFilesAction = actionCollection()->action("compare_files");
|
|
|
|
compareFilesAction->setEnabled(selectedUrlsCount == 2);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::slotHistoryChanged()
|
|
|
|
{
|
|
|
|
updateHistory();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateFilterBarAction(bool show)
|
|
|
|
{
|
|
|
|
KToggleAction* showFilterBarAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
|
|
|
|
showFilterBarAction->setChecked(show);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::openNewMainWindow()
|
|
|
|
{
|
|
|
|
DolphinApplication::app()->createMainWindow()->show();
|
|
|
|
}
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
void DolphinMainWindow::toggleActiveView()
|
|
|
|
{
|
2007-06-27 15:15:29 +00:00
|
|
|
if (m_viewContainer[SecondaryView] == 0) {
|
|
|
|
// 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);
|
|
|
|
Q_ASSERT(m_viewContainer[PrimaryView] != 0);
|
|
|
|
|
|
|
|
DolphinViewContainer* left = m_viewContainer[PrimaryView];
|
|
|
|
DolphinViewContainer* right = m_viewContainer[SecondaryView];
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::saveProperties(KConfig* config)
|
|
|
|
{
|
|
|
|
KConfigGroup primaryView = config->group("Primary view");
|
2007-06-12 21:45:22 +00:00
|
|
|
primaryView.writeEntry("Url", m_viewContainer[PrimaryView]->url().url());
|
|
|
|
primaryView.writeEntry("Editable Url", m_viewContainer[PrimaryView]->isUrlEditable());
|
|
|
|
if (m_viewContainer[SecondaryView] != 0) {
|
2007-04-01 18:36:23 +00:00
|
|
|
KConfigGroup secondaryView = config->group("Secondary view");
|
2007-06-12 21:45:22 +00:00
|
|
|
secondaryView.writeEntry("Url", m_viewContainer[SecondaryView]->url().url());
|
|
|
|
secondaryView.writeEntry("Editable Url", m_viewContainer[SecondaryView]->isUrlEditable());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::readProperties(KConfig* config)
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
const KConfigGroup primaryViewGroup = config->group("Primary view");
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[PrimaryView]->setUrl(primaryViewGroup.readEntry("Url"));
|
2007-06-07 21:10:48 +00:00
|
|
|
bool editable = primaryViewGroup.readEntry("Editable Url", false);
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[PrimaryView]->urlNavigator()->setUrlEditable(editable);
|
2007-06-07 21:10:48 +00:00
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
if (config->hasGroup("Secondary view")) {
|
2007-06-07 21:10:48 +00:00
|
|
|
const KConfigGroup secondaryViewGroup = config->group("Secondary view");
|
2007-06-12 21:45:22 +00:00
|
|
|
if (m_viewContainer[PrimaryView] == 0) {
|
2007-04-01 18:36:23 +00:00
|
|
|
toggleSplitView();
|
|
|
|
}
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[PrimaryView]->setUrl(secondaryViewGroup.readEntry("Url"));
|
2007-06-07 21:10:48 +00:00
|
|
|
editable = secondaryViewGroup.readEntry("Editable Url", false);
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[PrimaryView]->urlNavigator()->setUrlEditable(editable);
|
|
|
|
} else if (m_viewContainer[SecondaryView] != 0) {
|
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::rename()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->renameSelectedItems();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::moveToTrash()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl::List selectedUrls = m_activeViewContainer->view()->selectedUrls();
|
2007-04-01 18:36:23 +00:00
|
|
|
KonqOperations::del(this, KonqOperations::TRASH, selectedUrls);
|
|
|
|
m_undoCommandTypes.append(KonqUndoManager::TRASH);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::deleteItems()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl::List list = m_activeViewContainer->view()->selectedUrls();
|
2007-04-01 19:08:49 +00:00
|
|
|
const bool del = KonqOperations::askDeleteConfirmation(list,
|
2007-04-09 19:12:54 +00:00
|
|
|
KonqOperations::DEL,
|
|
|
|
KonqOperations::DEFAULT_CONFIRMATION,
|
|
|
|
this);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
if (del) {
|
|
|
|
KIO::Job* job = KIO::del(list);
|
|
|
|
connect(job, SIGNAL(result(KJob*)),
|
|
|
|
this, SLOT(slotHandleJobError(KJob*)));
|
|
|
|
connect(job, SIGNAL(result(KJob*)),
|
|
|
|
this, SLOT(slotDeleteFileFinished(KJob*)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::properties()
|
|
|
|
{
|
2007-08-13 21:57:20 +00:00
|
|
|
QList<KFileItem> list = m_activeViewContainer->view()->selectedItems();
|
|
|
|
// ### KPropertiesDialog still uses pointer-based KFileItemList
|
|
|
|
KFileItemList lst;
|
|
|
|
// Can't be a const_iterator :(
|
|
|
|
for ( QList<KFileItem>::iterator it = list.begin(), end = list.end() ; it != end ; ++it ) {
|
|
|
|
lst << & *it; // ugly!
|
|
|
|
}
|
|
|
|
KPropertiesDialog dialog(lst, this);
|
2007-05-28 04:32:57 +00:00
|
|
|
dialog.exec();
|
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::slotHandleJobError(KJob* job)
|
|
|
|
{
|
|
|
|
if (job->error() != 0) {
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
|
2007-04-01 18:36:23 +00:00
|
|
|
statusBar->setMessage(job->errorString(),
|
|
|
|
DolphinStatusBar::Error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotDeleteFileFinished(KJob* job)
|
|
|
|
{
|
|
|
|
if (job->error() == 0) {
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
|
2007-06-30 20:10:50 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Delete operation completed."),
|
2007-04-01 18:36:23 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotUndoAvailable(bool available)
|
|
|
|
{
|
|
|
|
QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
|
|
|
|
if (undoAction != 0) {
|
|
|
|
undoAction->setEnabled(available);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (available && (m_undoCommandTypes.count() > 0)) {
|
|
|
|
const KonqUndoManager::CommandType command = m_undoCommandTypes.takeFirst();
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
|
2007-04-01 18:36:23 +00:00
|
|
|
switch (command) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case KonqUndoManager::COPY:
|
2007-06-30 20:10:50 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Copy operation completed."),
|
2007-04-09 19:12:54 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KonqUndoManager::MOVE:
|
2007-06-30 20:10:50 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Move operation completed."),
|
2007-04-09 19:12:54 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KonqUndoManager::LINK:
|
2007-06-30 20:10:50 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Link operation completed."),
|
2007-04-09 19:12:54 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KonqUndoManager::TRASH:
|
2007-06-30 20:10:50 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."),
|
2007-04-09 19:12:54 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
case KonqUndoManager::RENAME:
|
2007-06-30 20:10:50 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."),
|
2007-04-09 19:12:54 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KonqUndoManager::MKDIR:
|
2007-06-30 20:10:50 +00:00
|
|
|
statusBar->setMessage(i18nc("@info:status", "Created folder."),
|
2007-04-09 19:12:54 +00:00
|
|
|
DolphinStatusBar::OperationCompleted);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
|
|
|
|
{
|
|
|
|
QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
|
|
|
|
if (undoAction != 0) {
|
|
|
|
undoAction->setText(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::undo()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
KonqUndoManager::self()->undo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::cut()
|
|
|
|
{
|
|
|
|
QMimeData* mimeData = new QMimeData();
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl::List kdeUrls = m_activeViewContainer->view()->selectedUrls();
|
2007-04-01 18:36:23 +00:00
|
|
|
const KUrl::List mostLocalUrls;
|
|
|
|
KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true);
|
|
|
|
QApplication::clipboard()->setMimeData(mimeData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::copy()
|
|
|
|
{
|
|
|
|
QMimeData* mimeData = new QMimeData();
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrl::List kdeUrls = m_activeViewContainer->view()->selectedUrls();
|
2007-04-01 18:36:23 +00:00
|
|
|
const KUrl::List mostLocalUrls;
|
|
|
|
KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false);
|
|
|
|
|
|
|
|
QApplication::clipboard()->setMimeData(mimeData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::paste()
|
|
|
|
{
|
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
|
|
|
const QMimeData* mimeData = clipboard->mimeData();
|
|
|
|
|
|
|
|
clearStatusBar();
|
|
|
|
|
|
|
|
const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
|
|
|
|
|
|
|
|
// per default the pasting is done into the current Url of the view
|
2007-06-07 21:10:48 +00:00
|
|
|
KUrl destUrl(m_activeViewContainer->url());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
// check whether the pasting should be done into a selected directory
|
2007-06-07 21:10:48 +00:00
|
|
|
KUrl::List selectedUrls = m_activeViewContainer->view()->selectedUrls();
|
2007-04-01 18:36:23 +00:00
|
|
|
if (selectedUrls.count() == 1) {
|
|
|
|
const KFileItem fileItem(S_IFDIR,
|
|
|
|
KFileItem::Unknown,
|
|
|
|
selectedUrls.first(),
|
|
|
|
true);
|
|
|
|
if (fileItem.isDir()) {
|
|
|
|
// only one item is selected which is a directory, hence paste
|
|
|
|
// into this directory
|
|
|
|
destUrl = selectedUrls.first();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (KonqMimeData::decodeIsCutSelection(mimeData)) {
|
|
|
|
moveUrls(sourceUrls, destUrl);
|
|
|
|
clipboard->clear();
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-04-01 18:36:23 +00:00
|
|
|
copyUrls(sourceUrls, destUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updatePasteAction()
|
|
|
|
{
|
|
|
|
QAction* pasteAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste));
|
|
|
|
if (pasteAction == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-30 20:10:50 +00:00
|
|
|
QString text(i18nc("@action:inmenu", "Paste"));
|
2007-04-01 18:36:23 +00:00
|
|
|
QClipboard* clipboard = QApplication::clipboard();
|
|
|
|
const QMimeData* mimeData = clipboard->mimeData();
|
|
|
|
|
|
|
|
KUrl::List urls = KUrl::List::fromMimeData(mimeData);
|
|
|
|
if (!urls.isEmpty()) {
|
|
|
|
pasteAction->setEnabled(true);
|
|
|
|
|
2007-07-08 21:09:48 +00:00
|
|
|
pasteAction->setText(i18ncp("@action:inmenu", "Paste One File", "Paste %1 Files", urls.count()));
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-04-01 18:36:23 +00:00
|
|
|
pasteAction->setEnabled(false);
|
2007-06-30 20:10:50 +00:00
|
|
|
pasteAction->setText(i18nc("@action:inmenu", "Paste"));
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pasteAction->isEnabled()) {
|
2007-06-07 21:10:48 +00:00
|
|
|
KUrl::List urls = m_activeViewContainer->view()->selectedUrls();
|
2007-04-01 18:36:23 +00:00
|
|
|
const uint count = urls.count();
|
|
|
|
if (count > 1) {
|
|
|
|
// pasting should not be allowed when more than one file
|
|
|
|
// is selected
|
|
|
|
pasteAction->setEnabled(false);
|
2007-04-09 19:12:54 +00:00
|
|
|
} else if (count == 1) {
|
2007-04-01 18:36:23 +00:00
|
|
|
// Only one file is selected. Pasting is only allowed if this
|
|
|
|
// file is a directory.
|
|
|
|
// TODO: this doesn't work with remote protocols; instead we need a
|
2007-06-07 21:10:48 +00:00
|
|
|
// m_activeViewContainer->selectedFileItems() to get the real KFileItems
|
2007-04-01 18:36:23 +00:00
|
|
|
const KFileItem fileItem(S_IFDIR,
|
|
|
|
KFileItem::Unknown,
|
|
|
|
urls.first(),
|
|
|
|
true);
|
|
|
|
pasteAction->setEnabled(fileItem.isDir());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::selectAll()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
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::setIconsView()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setMode(DolphinView::IconsView);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::setDetailsView()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setMode(DolphinView::DetailsView);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::setColumnView()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setMode(DolphinView::ColumnView);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::sortByName()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByName);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::sortBySize()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortBySize);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::sortByDate()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByDate);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::sortByPermissions()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByPermissions);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::sortByOwner()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByOwner);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::sortByGroup()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByGroup);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-04-22 21:04:46 +00:00
|
|
|
void DolphinMainWindow::sortByType()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByType);
|
2007-04-22 21:04:46 +00:00
|
|
|
}
|
|
|
|
|
2007-06-22 10:18:46 +00:00
|
|
|
void DolphinMainWindow::sortByRating()
|
|
|
|
{
|
2007-06-23 13:12:21 +00:00
|
|
|
#ifdef HAVE_NEPOMUK
|
2007-06-22 10:18:46 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByRating);
|
2007-06-23 13:12:21 +00:00
|
|
|
#endif
|
2007-06-22 10:18:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::sortByTags()
|
|
|
|
{
|
2007-06-23 13:12:21 +00:00
|
|
|
#ifdef HAVE_NEPOMUK
|
2007-06-22 10:18:46 +00:00
|
|
|
m_activeViewContainer->view()->setSorting(DolphinView::SortByTags);
|
2007-06-23 13:12:21 +00:00
|
|
|
#endif
|
2007-06-22 10:18:46 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::toggleSortOrder()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinView* view = m_activeViewContainer->view();
|
|
|
|
const Qt::SortOrder order = (view->sortOrder() == Qt::AscendingOrder) ?
|
2007-04-04 13:02:52 +00:00
|
|
|
Qt::DescendingOrder :
|
|
|
|
Qt::AscendingOrder;
|
2007-06-07 21:10:48 +00:00
|
|
|
view->setSortOrder(order);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-04-10 11:22:56 +00:00
|
|
|
void DolphinMainWindow::toggleSortCategorization()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinView* view = m_activeViewContainer->view();
|
|
|
|
const bool categorizedSorting = view->categorizedSorting();
|
|
|
|
view->setCategorizedSorting(!categorizedSorting);
|
2007-04-10 11:22:56 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
void DolphinMainWindow::clearInfo()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::NoInformation);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::showMimeInfo()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::FriendlyMimeType);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::showSizeInfo()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::Size);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::showDateInfo()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setAdditionalInfo(KFileItemDelegate::ModificationTime);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::toggleSplitView()
|
|
|
|
{
|
2007-06-12 21:45:22 +00:00
|
|
|
if (m_viewContainer[SecondaryView] == 0) {
|
2007-04-01 18:36:23 +00:00
|
|
|
// create a secondary view
|
2007-08-12 17:48:29 +00:00
|
|
|
const int newWidth = (m_viewContainer[PrimaryView]->width() - m_splitter->handleWidth()) / 2;
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
const DolphinView* view = m_viewContainer[PrimaryView]->view();
|
2007-08-12 17:48:29 +00:00
|
|
|
m_viewContainer[SecondaryView] = new DolphinViewContainer(this, 0, view->rootUrl());
|
2007-06-12 21:45:22 +00:00
|
|
|
connectViewSignals(SecondaryView);
|
|
|
|
m_splitter->addWidget(m_viewContainer[SecondaryView]);
|
2007-04-01 18:36:23 +00:00
|
|
|
m_splitter->setSizes(QList<int>() << newWidth << newWidth);
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[SecondaryView]->view()->reload();
|
|
|
|
m_viewContainer[SecondaryView]->setActive(false);
|
|
|
|
m_viewContainer[SecondaryView]->show();
|
2007-08-12 17:48:29 +00:00
|
|
|
} else if (m_activeViewContainer == m_viewContainer[PrimaryView]) {
|
2007-04-01 18:36:23 +00:00
|
|
|
// remove secondary view
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[SecondaryView]->close();
|
|
|
|
m_viewContainer[SecondaryView]->deleteLater();
|
|
|
|
m_viewContainer[SecondaryView] = 0;
|
2007-08-12 17:48:29 +00:00
|
|
|
} else {
|
|
|
|
// The secondary view is active, hence from a users point of view
|
|
|
|
// 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.
|
|
|
|
m_viewContainer[PrimaryView]->close();
|
|
|
|
m_viewContainer[PrimaryView]->deleteLater();
|
|
|
|
m_viewContainer[PrimaryView] = m_viewContainer[SecondaryView];
|
|
|
|
m_viewContainer[SecondaryView] = 0;
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-06-07 21:41:22 +00:00
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
setActiveViewContainer(m_viewContainer[PrimaryView]);
|
2007-06-07 21:41:22 +00:00
|
|
|
updateViewActions();
|
2007-04-01 18:36:23 +00:00
|
|
|
emit activeViewChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
void DolphinMainWindow::togglePreview()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
|
|
|
|
const KToggleAction* showPreviewAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
|
|
|
|
const bool show = showPreviewAction->isChecked();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setShowPreview(show);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::toggleShowHiddenFiles()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
|
|
|
|
const KToggleAction* showHiddenFilesAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
|
|
|
|
const bool show = showHiddenFilesAction->isChecked();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->setShowHiddenFiles(show);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 21:50:24 +00:00
|
|
|
void DolphinMainWindow::toggleFilterBarVisibility()
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
const KToggleAction* showFilterBarAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
|
|
|
|
const bool show = showFilterBarAction->isChecked();
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->showFilterBar(show);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::zoomIn()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->zoomIn();
|
2007-04-01 18:36:23 +00:00
|
|
|
updateViewActions();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::zoomOut()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->view()->zoomOut();
|
2007-04-01 18:36:23 +00:00
|
|
|
updateViewActions();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::toggleEditLocation()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
|
|
|
|
|
|
|
KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
|
|
|
|
|
|
|
|
bool editOrBrowse = action->isChecked();
|
2007-06-07 21:10:48 +00:00
|
|
|
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
|
|
|
urlNavigator->setUrlEditable(editOrBrowse);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::editLocation()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->urlNavigator()->setUrlEditable(true);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::adjustViewProperties()
|
|
|
|
{
|
|
|
|
clearStatusBar();
|
2007-06-07 21:10:48 +00:00
|
|
|
ViewPropertiesDialog dlg(m_activeViewContainer->view());
|
2007-04-01 18:36:23 +00:00
|
|
|
dlg.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
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::findFile()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
KRun::run("kfind", m_activeViewContainer->url(), this);
|
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
|
2007-06-12 21:45:22 +00:00
|
|
|
Q_ASSERT(m_viewContainer[PrimaryView] != 0);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KUrl urlA;
|
|
|
|
KUrl urlB;
|
2007-06-12 21:45:22 +00:00
|
|
|
KUrl::List urls = m_viewContainer[PrimaryView]->view()->selectedUrls();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
switch (urls.count()) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case 0: {
|
2007-06-12 21:45:22 +00:00
|
|
|
Q_ASSERT(m_viewContainer[SecondaryView] != 0);
|
|
|
|
urls = m_viewContainer[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];
|
2007-06-12 21:45:22 +00:00
|
|
|
Q_ASSERT(m_viewContainer[SecondaryView] != 0);
|
|
|
|
urls = m_viewContainer[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
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::editSettings()
|
|
|
|
{
|
2007-05-05 21:02:04 +00:00
|
|
|
DolphinSettingsDialog dialog(this);
|
|
|
|
dialog.exec();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::init()
|
|
|
|
{
|
|
|
|
// Check whether Dolphin runs the first time. If yes then
|
|
|
|
// a proper default window size is given at the end of DolphinMainWindow::init().
|
|
|
|
GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
|
|
|
|
const bool firstRun = generalSettings->firstRun();
|
|
|
|
if (firstRun) {
|
|
|
|
generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
|
|
|
m_splitter = new QSplitter(this);
|
|
|
|
|
|
|
|
DolphinSettings& settings = DolphinSettings::instance();
|
|
|
|
|
|
|
|
setupActions();
|
|
|
|
|
|
|
|
const KUrl& homeUrl = settings.generalSettings()->homeUrl();
|
|
|
|
setCaption(homeUrl.fileName());
|
|
|
|
ViewProperties props(homeUrl);
|
2007-06-12 21:45:22 +00:00
|
|
|
m_viewContainer[PrimaryView] = new DolphinViewContainer(this,
|
2007-06-19 16:35:52 +00:00
|
|
|
m_splitter,
|
|
|
|
homeUrl);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
m_activeViewContainer = m_viewContainer[PrimaryView];
|
|
|
|
connectViewSignals(PrimaryView);
|
|
|
|
m_viewContainer[PrimaryView]->view()->reload();
|
|
|
|
m_viewContainer[PrimaryView]->show();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
setCentralWidget(m_splitter);
|
|
|
|
setupDockWidgets();
|
|
|
|
|
2007-04-09 19:12:54 +00:00
|
|
|
setupGUI(Keys | Save | Create | ToolBar);
|
2007-04-01 18:36:23 +00:00
|
|
|
createGUI();
|
|
|
|
|
|
|
|
stateChanged("new_file");
|
|
|
|
setAutoSaveSettings();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if (firstRun) {
|
|
|
|
// assure a proper default size if Dolphin runs the first time
|
2007-06-07 21:10:48 +00:00
|
|
|
resize(700, 500);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-06-11 21:46:04 +00:00
|
|
|
#ifdef HAVE_NEPOMUK
|
2007-06-30 20:10:50 +00:00
|
|
|
if (!MetaDataWidget::metaDataAvailable()) {
|
|
|
|
DolphinStatusBar* statusBar = activeViewContainer()->statusBar();
|
|
|
|
statusBar->setMessage(i18nc("@info:status",
|
|
|
|
"Failed to contact Nepomuk service, annotation and tagging are disabled."),
|
|
|
|
DolphinStatusBar::Error);
|
|
|
|
}
|
2007-04-09 19:12:54 +00:00
|
|
|
#endif
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
emit urlChanged(homeUrl);
|
|
|
|
}
|
|
|
|
|
2007-06-12 21:45:22 +00:00
|
|
|
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* view)
|
|
|
|
{
|
2007-06-27 15:15:29 +00:00
|
|
|
Q_ASSERT(view != 0);
|
2007-06-12 21:45:22 +00:00
|
|
|
Q_ASSERT((view == m_viewContainer[PrimaryView]) || (view == m_viewContainer[SecondaryView]));
|
2007-06-27 15:15:29 +00:00
|
|
|
if (m_activeViewContainer == view) {
|
2007-06-12 21:45:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_activeViewContainer->setActive(false);
|
|
|
|
m_activeViewContainer = view;
|
|
|
|
m_activeViewContainer->setActive(true);
|
|
|
|
|
|
|
|
updateHistory();
|
|
|
|
updateEditActions();
|
|
|
|
updateViewActions();
|
|
|
|
updateGoActions();
|
|
|
|
|
2007-06-13 17:08:39 +00:00
|
|
|
const KUrl& url = m_activeViewContainer->url();
|
|
|
|
setCaption(url.fileName());
|
2007-06-12 21:45:22 +00:00
|
|
|
|
|
|
|
emit activeViewChanged();
|
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();
|
2007-06-30 20:10:50 +00:00
|
|
|
menu->setTitle(i18nc("@title:menu", "Create New"));
|
2007-04-01 18:36:23 +00:00
|
|
|
menu->setIcon(KIcon("document-new"));
|
|
|
|
connect(menu, SIGNAL(aboutToShow()),
|
|
|
|
this, SLOT(updateNewMenu()));
|
|
|
|
|
|
|
|
QAction* newWindow = actionCollection()->addAction("new_window");
|
|
|
|
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()));
|
|
|
|
|
|
|
|
QAction* rename = actionCollection()->addAction("rename");
|
2007-06-30 20:10:50 +00:00
|
|
|
rename->setText(i18nc("@action:inmenu File", "Rename..."));
|
2007-04-01 18:36:23 +00:00
|
|
|
rename->setShortcut(Qt::Key_F2);
|
|
|
|
connect(rename, SIGNAL(triggered()), this, SLOT(rename()));
|
|
|
|
|
|
|
|
QAction* moveToTrash = actionCollection()->addAction("move_to_trash");
|
2007-06-30 20:10:50 +00:00
|
|
|
moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash"));
|
2007-04-01 18:36:23 +00:00
|
|
|
moveToTrash->setIcon(KIcon("edit-trash"));
|
|
|
|
moveToTrash->setShortcut(QKeySequence::Delete);
|
|
|
|
connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash()));
|
|
|
|
|
|
|
|
QAction* deleteAction = actionCollection()->addAction("delete");
|
2007-06-30 20:10:50 +00:00
|
|
|
deleteAction->setText(i18nc("@action:inmenu File", "Delete"));
|
2007-04-01 18:36:23 +00:00
|
|
|
deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete);
|
|
|
|
deleteAction->setIcon(KIcon("edit-delete"));
|
|
|
|
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems()));
|
|
|
|
|
|
|
|
QAction* properties = actionCollection()->addAction("properties");
|
2007-06-30 20:10:50 +00:00
|
|
|
properties->setText(i18nc("@action:inmenu File", "Properties"));
|
2007-04-01 18:36:23 +00:00
|
|
|
properties->setShortcut(Qt::ALT | Qt::Key_Return);
|
|
|
|
connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
|
|
|
|
|
|
|
|
KStandardAction::quit(this, SLOT(quit()), actionCollection());
|
|
|
|
|
|
|
|
// setup 'Edit' menu
|
|
|
|
KStandardAction::undo(this,
|
|
|
|
SLOT(undo()),
|
|
|
|
actionCollection());
|
|
|
|
|
|
|
|
KStandardAction::cut(this, SLOT(cut()), actionCollection());
|
|
|
|
KStandardAction::copy(this, SLOT(copy()), actionCollection());
|
|
|
|
KStandardAction::paste(this, SLOT(paste()), actionCollection());
|
|
|
|
|
|
|
|
QAction* 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()));
|
|
|
|
|
|
|
|
QAction* 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
|
|
|
|
KStandardAction::zoomIn(this,
|
2007-04-09 19:12:54 +00:00
|
|
|
SLOT(zoomIn()),
|
|
|
|
actionCollection());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KStandardAction::zoomOut(this,
|
2007-04-09 19:12:54 +00:00
|
|
|
SLOT(zoomOut()),
|
|
|
|
actionCollection());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KToggleAction* iconsView = actionCollection()->add<KToggleAction>("icons");
|
2007-06-30 20:10:50 +00:00
|
|
|
iconsView->setText(i18nc("@action:inmenu View Mode", "Icons"));
|
2007-04-01 18:36:23 +00:00
|
|
|
iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
|
2007-06-03 13:31:16 +00:00
|
|
|
iconsView->setIcon(KIcon("fileview-icon"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(iconsView, SIGNAL(triggered()), this, SLOT(setIconsView()));
|
|
|
|
|
|
|
|
KToggleAction* detailsView = actionCollection()->add<KToggleAction>("details");
|
2007-06-30 20:10:50 +00:00
|
|
|
detailsView->setText(i18nc("@action:inmenu View Mode", "Details"));
|
2007-04-01 18:36:23 +00:00
|
|
|
detailsView->setShortcut(Qt::CTRL | Qt::Key_2);
|
2007-06-03 13:56:06 +00:00
|
|
|
detailsView->setIcon(KIcon("fileview-detailed"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));
|
|
|
|
|
|
|
|
KToggleAction* columnView = actionCollection()->add<KToggleAction>("columns");
|
2007-06-30 20:10:50 +00:00
|
|
|
columnView->setText(i18nc("@action:inmenu View Mode", "Columns"));
|
2007-04-01 18:36:23 +00:00
|
|
|
columnView->setShortcut(Qt::CTRL | Qt::Key_3);
|
2007-04-16 20:08:09 +00:00
|
|
|
columnView->setIcon(KIcon("fileview-column"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(columnView, SIGNAL(triggered()), this, SLOT(setColumnView()));
|
|
|
|
|
|
|
|
QActionGroup* viewModeGroup = new QActionGroup(this);
|
|
|
|
viewModeGroup->addAction(iconsView);
|
|
|
|
viewModeGroup->addAction(detailsView);
|
|
|
|
viewModeGroup->addAction(columnView);
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByName = actionCollection()->add<KToggleAction>("sort_by_name");
|
|
|
|
sortByName->setText(i18nc("@action:inmenu Sort By", "Name"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortBySize = actionCollection()->add<KToggleAction>("sort_by_size");
|
|
|
|
sortBySize->setText(i18nc("@action:inmenu Sort By", "Size"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(sortBySize, SIGNAL(triggered()), this, SLOT(sortBySize()));
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByDate = actionCollection()->add<KToggleAction>("sort_by_date");
|
|
|
|
sortByDate->setText(i18nc("@action:inmenu Sort By", "Date"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate()));
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByPermissions = actionCollection()->add<KToggleAction>("sort_by_permissions");
|
|
|
|
sortByPermissions->setText(i18nc("@action:inmenu Sort By", "Permissions"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(sortByPermissions, SIGNAL(triggered()), this, SLOT(sortByPermissions()));
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByOwner = actionCollection()->add<KToggleAction>("sort_by_owner");
|
|
|
|
sortByOwner->setText(i18nc("@action:inmenu Sort By", "Owner"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(sortByOwner, SIGNAL(triggered()), this, SLOT(sortByOwner()));
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByGroup = actionCollection()->add<KToggleAction>("sort_by_group");
|
|
|
|
sortByGroup->setText(i18nc("@action:inmenu Sort By", "Group"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(sortByGroup, SIGNAL(triggered()), this, SLOT(sortByGroup()));
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByType = actionCollection()->add<KToggleAction>("sort_by_type");
|
|
|
|
sortByType->setText(i18nc("@action:inmenu Sort By", "Type"));
|
2007-04-22 21:04:46 +00:00
|
|
|
connect(sortByType, SIGNAL(triggered()), this, SLOT(sortByType()));
|
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByRating = actionCollection()->add<KToggleAction>("sort_by_rating");
|
|
|
|
sortByRating->setText(i18nc("@action:inmenu Sort By", "Rating"));
|
2007-06-22 10:18:46 +00:00
|
|
|
|
2007-07-13 18:14:41 +00:00
|
|
|
KToggleAction* sortByTags = actionCollection()->add<KToggleAction>("sort_by_tags");
|
|
|
|
sortByTags->setText(i18nc("@action:inmenu Sort By", "Tags"));
|
2007-06-22 10:18:46 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_NEPOMUK
|
|
|
|
if (MetaDataWidget::metaDataAvailable()) {
|
|
|
|
connect(sortByRating, SIGNAL(triggered()), this, SLOT(sortByRating()));
|
|
|
|
connect(sortByTags, SIGNAL(triggered()), this, SLOT(sortByTags()));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sortByRating->setEnabled(false);
|
|
|
|
sortByTags->setEnabled(false);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
sortByRating->setEnabled(false);
|
|
|
|
sortByTags->setEnabled(false);
|
|
|
|
#endif
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
QActionGroup* sortGroup = new QActionGroup(this);
|
|
|
|
sortGroup->addAction(sortByName);
|
|
|
|
sortGroup->addAction(sortBySize);
|
|
|
|
sortGroup->addAction(sortByDate);
|
|
|
|
sortGroup->addAction(sortByPermissions);
|
|
|
|
sortGroup->addAction(sortByOwner);
|
|
|
|
sortGroup->addAction(sortByGroup);
|
2007-04-22 21:04:46 +00:00
|
|
|
sortGroup->addAction(sortByType);
|
2007-06-22 10:18:46 +00:00
|
|
|
sortGroup->addAction(sortByRating);
|
|
|
|
sortGroup->addAction(sortByTags);
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KToggleAction* sortDescending = actionCollection()->add<KToggleAction>("descending");
|
2007-06-30 20:10:50 +00:00
|
|
|
sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
|
|
|
|
|
2007-06-19 16:00:21 +00:00
|
|
|
KToggleAction* showInGroups = actionCollection()->add<KToggleAction>("show_in_groups");
|
2007-06-30 20:10:50 +00:00
|
|
|
showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
|
2007-06-19 16:00:21 +00:00
|
|
|
connect(showInGroups, SIGNAL(triggered()), this, SLOT(toggleSortCategorization()));
|
2007-04-10 11:22:56 +00:00
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
KToggleAction* clearInfo = actionCollection()->add<KToggleAction>("clear_info");
|
2007-06-30 20:10:50 +00:00
|
|
|
clearInfo->setText(i18nc("@action:inmenu Additional information", "No Information"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(clearInfo, SIGNAL(triggered()), this, SLOT(clearInfo()));
|
|
|
|
|
|
|
|
KToggleAction* showMimeInfo = actionCollection()->add<KToggleAction>("show_mime_info");
|
2007-06-30 20:10:50 +00:00
|
|
|
showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(showMimeInfo, SIGNAL(triggered()), this, SLOT(showMimeInfo()));
|
|
|
|
|
|
|
|
KToggleAction* showSizeInfo = actionCollection()->add<KToggleAction>("show_size_info");
|
2007-06-30 20:10:50 +00:00
|
|
|
showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(showSizeInfo, SIGNAL(triggered()), this, SLOT(showSizeInfo()));
|
|
|
|
|
|
|
|
KToggleAction* showDateInfo = actionCollection()->add<KToggleAction>("show_date_info");
|
2007-06-30 20:10:50 +00:00
|
|
|
showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(showDateInfo, SIGNAL(triggered()), this, SLOT(showDateInfo()));
|
|
|
|
|
|
|
|
QActionGroup* infoGroup = new QActionGroup(this);
|
|
|
|
infoGroup->addAction(clearInfo);
|
|
|
|
infoGroup->addAction(showMimeInfo);
|
|
|
|
infoGroup->addAction(showSizeInfo);
|
|
|
|
infoGroup->addAction(showDateInfo);
|
|
|
|
|
|
|
|
KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview");
|
2007-06-30 20:10:50 +00:00
|
|
|
showPreview->setText(i18nc("@action:intoolbar", "Preview"));
|
2007-06-03 15:19:52 +00:00
|
|
|
showPreview->setIcon(KIcon("fileview-preview"));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
|
|
|
|
|
|
|
|
KToggleAction* showHiddenFiles = actionCollection()->add<KToggleAction>("show_hidden_files");
|
2007-06-30 20:10:50 +00:00
|
|
|
showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
|
2007-04-01 18:36:23 +00:00
|
|
|
showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);
|
|
|
|
connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
|
|
|
|
|
2007-06-03 15:50:52 +00:00
|
|
|
QAction* split = actionCollection()->addAction("split_view");
|
2007-04-01 18:36:23 +00:00
|
|
|
split->setShortcut(Qt::Key_F10);
|
2007-08-12 17:48:29 +00:00
|
|
|
updateSplitAction();
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
|
|
|
|
|
|
|
|
QAction* 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()));
|
|
|
|
|
|
|
|
QAction* 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()));
|
|
|
|
|
|
|
|
// TODO: the URL navigator must emit a signal if the editable state has been
|
|
|
|
// changed, so that the corresponding showFullLocation action is updated. Also
|
|
|
|
// the naming "Show full Location" is currently confusing...
|
|
|
|
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()));
|
|
|
|
|
|
|
|
QAction* 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()));
|
|
|
|
|
|
|
|
QAction* adjustViewProps = actionCollection()->addAction("view_properties");
|
2007-06-30 20:10:50 +00:00
|
|
|
adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Properties..."));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
|
|
|
|
|
|
|
|
// setup 'Go' menu
|
|
|
|
KStandardAction::back(this, SLOT(goBack()), actionCollection());
|
|
|
|
KStandardAction::forward(this, SLOT(goForward()), actionCollection());
|
|
|
|
KStandardAction::up(this, SLOT(goUp()), actionCollection());
|
|
|
|
KStandardAction::home(this, SLOT(goHome()), actionCollection());
|
|
|
|
|
|
|
|
// setup 'Tools' menu
|
|
|
|
QAction* findFile = actionCollection()->addAction("find_file");
|
2007-06-30 20:10:50 +00:00
|
|
|
findFile->setText(i18nc("@action:inmenu Tools", "Find File..."));
|
2007-04-14 17:21:53 +00:00
|
|
|
findFile->setShortcut(Qt::CTRL | Qt::Key_F);
|
2007-04-01 18:36:23 +00:00
|
|
|
findFile->setIcon(KIcon("file-find"));
|
|
|
|
connect(findFile, SIGNAL(triggered()), this, SLOT(findFile()));
|
|
|
|
|
|
|
|
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);
|
2007-05-06 21:50:24 +00:00
|
|
|
connect(showFilterBar, SIGNAL(triggered()), this, SLOT(toggleFilterBarVisibility()));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
QAction* 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()));
|
|
|
|
|
|
|
|
// setup 'Settings' menu
|
|
|
|
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-07-13 18:25:36 +00:00
|
|
|
infoDock->toggleViewAction()->setShortcut(Qt::Key_F8);
|
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-08-13 21:57:20 +00:00
|
|
|
connect(this, SIGNAL(selectionChanged(QList<KFileItem>)),
|
|
|
|
infoWidget, SLOT(setSelection(QList<KFileItem>)));
|
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-07-13 18:25:36 +00:00
|
|
|
treeViewDock->toggleViewAction()->setShortcut(Qt::Key_F9);
|
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)));
|
|
|
|
connect(treeWidget, SIGNAL(changeUrl(KUrl)),
|
|
|
|
this, SLOT(changeUrl(KUrl)));
|
2007-08-13 21:57:20 +00:00
|
|
|
connect(treeWidget, SIGNAL(changeSelection(QList<KFileItem>)),
|
|
|
|
this, SLOT(changeSelection(QList<KFileItem>)));
|
2007-05-02 05:15:03 +00:00
|
|
|
connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
|
|
|
|
this, SLOT(dropUrls(KUrl::List, KUrl)));
|
2007-04-01 18:36:23 +00:00
|
|
|
|
2007-05-06 21:50:24 +00:00
|
|
|
// setup "Terminal"
|
2007-06-30 20:10:50 +00:00
|
|
|
QDockWidget* terminalDock = new QDockWidget(i18nc("@title:window", "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-06-30 20:10:50 +00:00
|
|
|
terminalDock->toggleViewAction()->setText(i18nc("@title:window", "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)));
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
|
|
|
|
if (firstRun) {
|
2007-04-22 21:27:40 +00:00
|
|
|
infoDock->hide();
|
2007-04-01 18:36:23 +00:00
|
|
|
treeViewDock->hide();
|
2007-05-06 21:50:24 +00:00
|
|
|
terminalDock->hide();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
2007-04-01 22:28:03 +00:00
|
|
|
|
2007-06-30 20:10:50 +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);
|
2007-04-02 08:51:57 +00:00
|
|
|
KFilePlacesView *listView = new KFilePlacesView(placesDock);
|
2007-04-01 22:28:03 +00:00
|
|
|
placesDock->setWidget(listView);
|
2007-04-09 09:16:39 +00:00
|
|
|
listView->setModel(DolphinSettings::instance().placesModel());
|
2007-04-14 16:50:51 +00:00
|
|
|
|
2007-06-30 20:10:50 +00:00
|
|
|
placesDock->toggleViewAction()->setText(i18nc("@title:window", "Places"));
|
2007-07-13 18:25:36 +00:00
|
|
|
placesDock->toggleViewAction()->setShortcut(Qt::Key_F7);
|
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);
|
2007-04-02 08:51:57 +00:00
|
|
|
connect(listView, SIGNAL(urlChanged(KUrl)),
|
|
|
|
this, SLOT(changeUrl(KUrl)));
|
|
|
|
connect(this, SIGNAL(urlChanged(KUrl)),
|
|
|
|
listView, SLOT(setUrl(KUrl)));
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateHistory()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
|
2007-04-08 21:07:41 +00:00
|
|
|
const int index = urlNavigator->historyIndex();
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
QAction* backAction = actionCollection()->action("go_back");
|
|
|
|
if (backAction != 0) {
|
2007-04-08 21:07:41 +00:00
|
|
|
backAction->setEnabled(index < urlNavigator->historySize() - 1);
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QAction* forwardAction = actionCollection()->action("go_forward");
|
|
|
|
if (forwardAction != 0) {
|
|
|
|
forwardAction->setEnabled(index > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateEditActions()
|
|
|
|
{
|
2007-08-13 21:57:20 +00:00
|
|
|
const QList<KFileItem> 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");
|
|
|
|
|
|
|
|
QAction* renameAction = actionCollection()->action("rename");
|
|
|
|
if (renameAction != 0) {
|
|
|
|
renameAction->setEnabled(list.count() >= 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool enableMoveToTrash = true;
|
|
|
|
|
2007-08-13 21:57:20 +00:00
|
|
|
QList<KFileItem>::const_iterator it = list.begin();
|
|
|
|
const QList<KFileItem>::const_iterator end = list.end();
|
2007-04-01 18:36:23 +00:00
|
|
|
while (it != end) {
|
2007-08-13 21:57:20 +00:00
|
|
|
const KUrl& url = (*it).url();
|
2007-04-01 18:36:23 +00:00
|
|
|
// only enable the 'Move to Trash' action for local files
|
|
|
|
if (!url.isLocalFile()) {
|
|
|
|
enableMoveToTrash = false;
|
|
|
|
}
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
|
|
|
|
moveToTrashAction->setEnabled(enableMoveToTrash);
|
|
|
|
}
|
|
|
|
updatePasteAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::updateViewActions()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
const DolphinView* view = m_activeViewContainer->view();
|
2007-04-01 18:36:23 +00:00
|
|
|
QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn));
|
|
|
|
if (zoomInAction != 0) {
|
2007-06-07 21:10:48 +00:00
|
|
|
zoomInAction->setEnabled(view->isZoomInPossible());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut));
|
|
|
|
if (zoomOutAction != 0) {
|
2007-06-07 21:10:48 +00:00
|
|
|
zoomOutAction->setEnabled(view->isZoomOutPossible());
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QAction* action = 0;
|
2007-06-07 21:10:48 +00:00
|
|
|
switch (view->mode()) {
|
2007-04-09 19:12:54 +00:00
|
|
|
case DolphinView::IconsView:
|
|
|
|
action = actionCollection()->action("icons");
|
|
|
|
break;
|
|
|
|
case DolphinView::DetailsView:
|
|
|
|
action = actionCollection()->action("details");
|
|
|
|
break;
|
|
|
|
case DolphinView::ColumnView:
|
|
|
|
action = actionCollection()->action("columns");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action != 0) {
|
|
|
|
KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
|
|
|
|
toggleAction->setChecked(true);
|
|
|
|
}
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
slotSortingChanged(view->sorting());
|
|
|
|
slotSortOrderChanged(view->sortOrder());
|
2007-04-10 11:22:56 +00:00
|
|
|
slotCategorizedSortingChanged();
|
2007-06-07 21:10:48 +00:00
|
|
|
slotAdditionalInfoChanged(view->additionalInfo());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KToggleAction* showFilterBarAction =
|
|
|
|
static_cast<KToggleAction*>(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
|
|
|
|
|
|
|
KToggleAction* showPreviewAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
|
2007-06-07 21:10:48 +00:00
|
|
|
showPreviewAction->setChecked(view->showPreview());
|
2007-04-01 18:36:23 +00:00
|
|
|
|
|
|
|
KToggleAction* showHiddenFilesAction =
|
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
|
2007-06-07 21:10:48 +00:00
|
|
|
showHiddenFilesAction->setChecked(view->showHiddenFiles());
|
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
|
|
|
|
|
|
|
KToggleAction* editableLocactionAction =
|
|
|
|
static_cast<KToggleAction*>(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()
|
|
|
|
{
|
|
|
|
QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(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::copyUrls(const KUrl::List& source, const KUrl& dest)
|
|
|
|
{
|
|
|
|
KonqOperations::copy(this, KonqOperations::COPY, source, dest);
|
|
|
|
m_undoCommandTypes.append(KonqUndoManager::COPY);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
|
|
|
|
{
|
|
|
|
KonqOperations::copy(this, KonqOperations::MOVE, source, dest);
|
|
|
|
m_undoCommandTypes.append(KonqUndoManager::MOVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::linkUrls(const KUrl::List& source, const KUrl& dest)
|
|
|
|
{
|
|
|
|
KonqOperations::copy(this, KonqOperations::LINK, source, dest);
|
|
|
|
m_undoCommandTypes.append(KonqUndoManager::LINK);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::clearStatusBar()
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
m_activeViewContainer->statusBar()->clear();
|
2007-04-01 18:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinMainWindow::connectViewSignals(int viewIndex)
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinViewContainer* container = m_viewContainer[viewIndex];
|
|
|
|
connect(container, SIGNAL(showFilterBarChanged(bool)),
|
|
|
|
this, SLOT(updateFilterBarAction(bool)));
|
|
|
|
|
|
|
|
DolphinView* view = container->view();
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(view, SIGNAL(modeChanged()),
|
|
|
|
this, SLOT(slotViewModeChanged()));
|
|
|
|
connect(view, SIGNAL(showPreviewChanged()),
|
|
|
|
this, SLOT(slotShowPreviewChanged()));
|
|
|
|
connect(view, SIGNAL(showHiddenFilesChanged()),
|
|
|
|
this, SLOT(slotShowHiddenFilesChanged()));
|
2007-04-10 11:22:56 +00:00
|
|
|
connect(view, SIGNAL(categorizedSortingChanged()),
|
|
|
|
this, SLOT(slotCategorizedSortingChanged()));
|
2007-04-01 18:36:23 +00:00
|
|
|
connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
|
|
|
|
this, SLOT(slotSortingChanged(DolphinView::Sorting)));
|
|
|
|
connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
|
|
|
|
this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
|
|
|
|
connect(view, SIGNAL(additionalInfoChanged(KFileItemDelegate::AdditionalInformation)),
|
|
|
|
this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation)));
|
2007-08-13 21:57:20 +00:00
|
|
|
connect(view, SIGNAL(selectionChanged(QList<KFileItem>)),
|
|
|
|
this, SLOT(slotSelectionChanged(QList<KFileItem>)));
|
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()));
|
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()),
|
|
|
|
this, SLOT(slotHistoryChanged()));
|
|
|
|
}
|
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");
|
2007-08-12 17:48:29 +00:00
|
|
|
if (m_viewContainer[SecondaryView] != 0) {
|
2007-08-16 06:59:36 +00:00
|
|
|
splitAction->setText(i18nc("@action:intoolbar Close inactive view", "Close"));
|
2007-08-12 17:48:29 +00:00
|
|
|
if (m_activeViewContainer == m_viewContainer[PrimaryView]) {
|
|
|
|
splitAction->setIcon(KIcon("fileview-join"));
|
|
|
|
} else {
|
|
|
|
// TODO: replace by alternative icon as soon as it is available in Oxygen
|
|
|
|
splitAction->setIcon(KIcon("fileview-join"));
|
|
|
|
}
|
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"));
|
2007-06-03 14:07:45 +00:00
|
|
|
splitAction->setIcon(KIcon("fileview-split"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-01 18:36:23 +00:00
|
|
|
DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
|
2007-04-12 17:37:53 +00:00
|
|
|
KonqUndoManager::UiInterface(mainWin),
|
|
|
|
m_mainWin(mainWin)
|
2007-04-01 18:36:23 +00:00
|
|
|
{
|
|
|
|
Q_ASSERT(m_mainWin != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinStatusBar* statusBar = m_mainWin->activeViewContainer()->statusBar();
|
2007-04-01 18:36:23 +00:00
|
|
|
statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "dolphinmainwindow.moc"
|