]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
Revert r1053349 - this file is included alread when HAVE_NEPOMUK is defined - no...
[dolphin.git] / src / dolphinmainwindow.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #include "dolphinmainwindow.h"
23 #include "dolphinviewactionhandler.h"
24 #include "dolphinremoteencoding.h"
25
26 #include <config-nepomuk.h>
27 #ifdef HAVE_NEPOMUK
28 #include "search/dolphinsearchoptionsconfigurator.h"
29 #endif
30
31 #include "dolphinapplication.h"
32 #include "dolphinnewmenu.h"
33 #include "search/dolphinsearchbox.h"
34 #include "settings/dolphinsettings.h"
35 #include "settings/dolphinsettingsdialog.h"
36 #include "dolphinviewcontainer.h"
37 #include "panels/folders/folderspanel.h"
38 #include "panels/places/placespanel.h"
39 #include "panels/information/informationpanel.h"
40 #include "mainwindowadaptor.h"
41 #include "statusbar/dolphinstatusbar.h"
42 #include "viewproperties.h"
43
44 #ifndef Q_OS_WIN
45 #include "panels/terminal/terminalpanel.h"
46 #endif
47
48 #include "dolphin_generalsettings.h"
49 #include "dolphin_iconsmodesettings.h"
50 #include "draganddrophelper.h"
51
52 #include <kaction.h>
53 #include <kactioncollection.h>
54 #include <kconfig.h>
55 #include <kdesktopfile.h>
56 #include <kdeversion.h>
57 #include <kfiledialog.h>
58 #include <kfileplacesmodel.h>
59 #include <kglobal.h>
60 #include <klineedit.h>
61 #include <ktoolbar.h>
62 #include <kicon.h>
63 #include <kiconloader.h>
64 #include <kio/netaccess.h>
65 #include <kinputdialog.h>
66 #include <klocale.h>
67 #include <kprotocolmanager.h>
68 #include <kmenu.h>
69 #include <kmenubar.h>
70 #include <kmessagebox.h>
71 #include <kfileitemlistproperties.h>
72 #include <konqmimedata.h>
73 #include <kprotocolinfo.h>
74 #include <krun.h>
75 #include <kshell.h>
76 #include <kstandarddirs.h>
77 #include <kstatusbar.h>
78 #include <kstandardaction.h>
79 #include <ktabbar.h>
80 #include <ktoggleaction.h>
81 #include <kurlnavigator.h>
82 #include <kurl.h>
83 #include <kurlcombobox.h>
84 #include <ktoolinvocation.h>
85
86 #include <QDBusMessage>
87 #include <QKeyEvent>
88 #include <QClipboard>
89 #include <QSplitter>
90 #include <QDockWidget>
91 #include <kacceleratormanager.h>
92
93 /*
94 * Remembers the tab configuration if a tab has been closed.
95 * Each closed tab can be restored by the menu
96 * "Go -> Recently Closed Tabs".
97 */
98 struct ClosedTab
99 {
100 KUrl primaryUrl;
101 KUrl secondaryUrl;
102 bool isSplit;
103 };
104 Q_DECLARE_METATYPE(ClosedTab)
105
106 DolphinMainWindow::DolphinMainWindow(int id) :
107 KXmlGuiWindow(0),
108 m_newMenu(0),
109 m_showMenuBar(0),
110 m_tabBar(0),
111 m_activeViewContainer(0),
112 m_centralWidgetLayout(0),
113 m_searchBox(0),
114 #ifdef HAVE_NEPOMUK
115 m_searchOptionsConfigurator(0),
116 #endif
117 m_id(id),
118 m_tabIndex(0),
119 m_viewTab(),
120 m_actionHandler(0),
121 m_remoteEncoding(0),
122 m_settingsDialog(0)
123 {
124 setObjectName("Dolphin#");
125
126 m_viewTab.append(ViewTab());
127
128 new MainWindowAdaptor(this);
129 QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);
130
131 KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
132 undoManager->setUiInterface(new UndoUiInterface());
133
134 connect(undoManager, SIGNAL(undoAvailable(bool)),
135 this, SLOT(slotUndoAvailable(bool)));
136 connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
137 this, SLOT(slotUndoTextChanged(const QString&)));
138 connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)),
139 this, SLOT(clearStatusBar()));
140 connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
141 this, SLOT(showCommand(CommandType)));
142 connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)),
143 this, SLOT(showErrorMessage(const QString&)));
144 connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString&)),
145 this, SLOT(showErrorMessage(const QString&)));
146 }
147
148 DolphinMainWindow::~DolphinMainWindow()
149 {
150 DolphinApplication::app()->removeMainWindow(this);
151 }
152
153 void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
154 {
155 if (dirs.isEmpty()) {
156 return;
157 }
158
159 const int oldOpenTabsCount = m_viewTab.count();
160
161 const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
162 const bool hasSplitView = generalSettings->splitView();
163
164 // Open each directory inside a new tab. If the "split view" option has been enabled,
165 // always show two directories within one tab.
166 QList<KUrl>::const_iterator it = dirs.begin();
167 while (it != dirs.end()) {
168 openNewTab(*it);
169 ++it;
170
171 if (hasSplitView && (it != dirs.end())) {
172 const int tabIndex = m_viewTab.count() - 1;
173 m_viewTab[tabIndex].secondaryView->setUrl(*it);
174 ++it;
175 }
176 }
177
178 // remove the previously opened tabs
179 for (int i = 0; i < oldOpenTabsCount; ++i) {
180 closeTab(0);
181 }
182 }
183
184 void DolphinMainWindow::openFiles(const QList<KUrl>& files)
185 {
186 if (files.isEmpty()) {
187 return;
188 }
189
190 // Get all distinct directories from 'files' and open a tab
191 // for each directory. If the "split view" option is enabled, two
192 // directories are shown inside one tab (see openDirectories()).
193 QList<KUrl> dirs;
194 foreach (const KUrl& url, files) {
195 const KUrl dir(url.directory());
196 if (!dirs.contains(dir)) {
197 dirs.append(dir);
198 }
199 }
200
201 openDirectories(dirs);
202
203 // Select the files. Although the files can be split between several
204 // tabs, there is no need to split 'files' accordingly, as
205 // the DolphinView will just ignore invalid selections.
206 const int tabCount = m_viewTab.count();
207 for (int i = 0; i < tabCount; ++i) {
208 m_viewTab[i].primaryView->view()->markUrlsAsSelected(files);
209 if (m_viewTab[i].secondaryView != 0) {
210 m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files);
211 }
212 }
213 }
214
215 void DolphinMainWindow::toggleViews()
216 {
217 if (m_viewTab[m_tabIndex].primaryView == 0) {
218 return;
219 }
220
221 // move secondary view from the last position of the splitter
222 // to the first position
223 m_viewTab[m_tabIndex].splitter->insertWidget(0, m_viewTab[m_tabIndex].secondaryView);
224
225 DolphinViewContainer* container = m_viewTab[m_tabIndex].primaryView;
226 m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
227 m_viewTab[m_tabIndex].secondaryView = container;
228 }
229
230 void DolphinMainWindow::showCommand(CommandType command)
231 {
232 DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
233 switch (command) {
234 case KIO::FileUndoManager::Copy:
235 statusBar->setMessage(i18nc("@info:status", "Successfully copied."),
236 DolphinStatusBar::OperationCompleted);
237 break;
238 case KIO::FileUndoManager::Move:
239 statusBar->setMessage(i18nc("@info:status", "Successfully moved."),
240 DolphinStatusBar::OperationCompleted);
241 break;
242 case KIO::FileUndoManager::Link:
243 statusBar->setMessage(i18nc("@info:status", "Successfully linked."),
244 DolphinStatusBar::OperationCompleted);
245 break;
246 case KIO::FileUndoManager::Trash:
247 statusBar->setMessage(i18nc("@info:status", "Successfully moved to trash."),
248 DolphinStatusBar::OperationCompleted);
249 break;
250 case KIO::FileUndoManager::Rename:
251 statusBar->setMessage(i18nc("@info:status", "Successfully renamed."),
252 DolphinStatusBar::OperationCompleted);
253 break;
254
255 case KIO::FileUndoManager::Mkdir:
256 statusBar->setMessage(i18nc("@info:status", "Created folder."),
257 DolphinStatusBar::OperationCompleted);
258 break;
259
260 default:
261 break;
262 }
263 }
264
265 void DolphinMainWindow::refreshViews()
266 {
267 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
268
269 // remember the current active view, as because of
270 // the refreshing the active view might change to
271 // the secondary view
272 DolphinViewContainer* activeViewContainer = m_activeViewContainer;
273
274 const int tabCount = m_viewTab.count();
275 for (int i = 0; i < tabCount; ++i) {
276 m_viewTab[i].primaryView->refresh();
277 if (m_viewTab[i].secondaryView != 0) {
278 m_viewTab[i].secondaryView->refresh();
279 }
280 }
281
282 setActiveViewContainer(activeViewContainer);
283 }
284
285 void DolphinMainWindow::pasteIntoFolder()
286 {
287 m_activeViewContainer->view()->pasteIntoFolder();
288 }
289
290 void DolphinMainWindow::changeUrl(const KUrl& url)
291 {
292 if (!KProtocolManager::supportsListing(url)) {
293 // The URL navigator only checks for validity, not
294 // if the URL can be listed. An error message is
295 // shown due to DolphinViewContainer::restoreView().
296 return;
297 }
298
299 DolphinViewContainer* view = activeViewContainer();
300 if (view != 0) {
301 view->setUrl(url);
302 updateEditActions();
303 updateViewActions();
304 updateGoActions();
305 setUrlAsCaption(url);
306 if (m_viewTab.count() > 1) {
307 m_tabBar->setTabText(m_tabIndex, squeezedText(tabName(m_activeViewContainer->url())));
308 }
309 const QString iconName = KMimeType::iconNameForUrl(url);
310 m_tabBar->setTabIcon(m_tabIndex, KIcon(iconName));
311 emit urlChanged(url);
312 }
313 }
314
315 void DolphinMainWindow::slotEditableStateChanged(bool editable)
316 {
317 KToggleAction* editableLocationAction =
318 static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
319 editableLocationAction->setChecked(editable);
320 }
321
322 void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
323 {
324 updateEditActions();
325
326 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
327 int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedItemsCount();
328 if (m_viewTab[m_tabIndex].secondaryView != 0) {
329 selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedItemsCount();
330 }
331
332 QAction* compareFilesAction = actionCollection()->action("compare_files");
333 if (selectedUrlsCount == 2) {
334 compareFilesAction->setEnabled(isKompareInstalled());
335 } else {
336 compareFilesAction->setEnabled(false);
337 }
338
339 emit selectionChanged(selection);
340 }
341
342 void DolphinMainWindow::slotWheelMoved(int wheelDelta)
343 {
344 if (wheelDelta > 0) {
345 activatePrevTab();
346 } else {
347 activateNextTab();
348 }
349 }
350
351 void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
352 {
353 emit requestItemInfo(item);
354 }
355
356 void DolphinMainWindow::updateHistory()
357 {
358 const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
359 const int index = urlNavigator->historyIndex();
360
361 QAction* backAction = actionCollection()->action("go_back");
362 backAction->setToolTip(i18nc("@info", "Go back"));
363 if (backAction != 0) {
364 backAction->setEnabled(index < urlNavigator->historySize() - 1);
365 }
366
367 QAction* forwardAction = actionCollection()->action("go_forward");
368 forwardAction->setToolTip(i18nc("@info", "Go forward"));
369 if (forwardAction != 0) {
370 forwardAction->setEnabled(index > 0);
371 }
372 }
373
374 void DolphinMainWindow::updateFilterBarAction(bool show)
375 {
376 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
377 showFilterBarAction->setChecked(show);
378 }
379
380 void DolphinMainWindow::openNewMainWindow()
381 {
382 DolphinApplication::app()->createMainWindow()->show();
383 }
384
385 void DolphinMainWindow::openNewTab()
386 {
387 openNewTab(m_activeViewContainer->url());
388 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
389
390 KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
391 if (navigator->isUrlEditable()) {
392 // if a new tab is opened and the URL is editable, assure that
393 // the user can edit the URL without manually setting the focus
394 navigator->setFocus();
395 }
396 }
397
398 void DolphinMainWindow::openNewTab(const KUrl& url)
399 {
400 const KIcon icon = KIcon(KMimeType::iconNameForUrl(m_activeViewContainer->url()));
401 if (m_viewTab.count() == 1) {
402 // Only one view is open currently and hence no tab is shown at
403 // all. Before creating a tab for 'url', provide a tab for the current URL.
404 m_tabBar->addTab(icon, squeezedText(tabName(m_activeViewContainer->url())));
405 m_tabBar->blockSignals(false);
406 }
407
408 m_tabBar->addTab(icon, squeezedText(tabName(url)));
409
410 ViewTab viewTab;
411 viewTab.splitter = new QSplitter(this);
412 viewTab.splitter->setChildrenCollapsible(false);
413 viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
414 viewTab.primaryView->setActive(false);
415 connectViewSignals(viewTab.primaryView);
416 viewTab.primaryView->view()->reload();
417
418 m_viewTab.append(viewTab);
419
420 actionCollection()->action("close_tab")->setEnabled(true);
421
422 // provide a split view, if the startup settings are set this way
423 const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
424 if (generalSettings->splitView()) {
425 const int tabIndex = m_viewTab.count() - 1;
426 createSecondaryView(tabIndex);
427 m_viewTab[tabIndex].secondaryView->setActive(true);
428 m_viewTab[tabIndex].isPrimaryViewActive = false;
429 }
430 }
431
432 void DolphinMainWindow::activateNextTab()
433 {
434 if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
435 return;
436 }
437
438 const int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count();
439 m_tabBar->setCurrentIndex(tabIndex);
440 }
441
442 void DolphinMainWindow::activatePrevTab()
443 {
444 if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
445 return;
446 }
447
448 int tabIndex = m_tabBar->currentIndex() - 1;
449 if (tabIndex == -1) {
450 tabIndex = m_tabBar->count() - 1;
451 }
452 m_tabBar->setCurrentIndex(tabIndex);
453 }
454
455 void DolphinMainWindow::openInNewTab()
456 {
457 const KFileItemList list = m_activeViewContainer->view()->selectedItems();
458 if ((list.count() == 1) && list[0].isDir()) {
459 openNewTab(m_activeViewContainer->view()->selectedUrls()[0]);
460 }
461 }
462
463 void DolphinMainWindow::openInNewWindow()
464 {
465 const KFileItemList list = m_activeViewContainer->view()->selectedItems();
466 if ((list.count() == 1) && list[0].isDir()) {
467 DolphinMainWindow* window = DolphinApplication::app()->createMainWindow();
468 window->changeUrl(m_activeViewContainer->view()->selectedUrls()[0]);
469 window->show();
470 }
471 }
472
473 void DolphinMainWindow::toggleActiveView()
474 {
475 if (m_viewTab[m_tabIndex].secondaryView == 0) {
476 // only one view is available
477 return;
478 }
479
480 Q_ASSERT(m_activeViewContainer != 0);
481 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
482
483 DolphinViewContainer* left = m_viewTab[m_tabIndex].primaryView;
484 DolphinViewContainer* right = m_viewTab[m_tabIndex].secondaryView;
485 setActiveViewContainer(m_activeViewContainer == right ? left : right);
486 }
487
488 void DolphinMainWindow::closeEvent(QCloseEvent* event)
489 {
490 DolphinSettings& settings = DolphinSettings::instance();
491 GeneralSettings* generalSettings = settings.generalSettings();
492
493 // Find out if Dolphin is closed directly by the user or
494 // by the session manager because the session is closed
495 bool closedByUser = true;
496 DolphinApplication *application = qobject_cast<DolphinApplication*>(qApp);
497 if (application && application->sessionSaving()) {
498 closedByUser = false;
499 }
500
501 if ((m_viewTab.count() > 1) && generalSettings->confirmClosingMultipleTabs() && closedByUser) {
502 // Ask the user if he really wants to quit and close all tabs.
503 // Open a confirmation dialog with 3 buttons:
504 // KDialog::Yes -> Quit
505 // KDialog::No -> Close only the current tab
506 // KDialog::Cancel -> do nothing
507 KDialog *dialog = new KDialog(this, Qt::Dialog);
508 dialog->setCaption(i18nc("@title:window", "Confirmation"));
509 dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel);
510 dialog->setModal(true);
511 dialog->showButtonSeparator(true);
512 dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit());
513 dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")));
514 dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel());
515 dialog->setDefaultButton(KDialog::Yes);
516
517 bool doNotAskAgainCheckboxResult = false;
518
519 const int result = KMessageBox::createKMessageBox(dialog,
520 QMessageBox::Warning,
521 i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
522 QStringList(),
523 i18n("Do not ask again"),
524 &doNotAskAgainCheckboxResult,
525 KMessageBox::Notify);
526
527 if (doNotAskAgainCheckboxResult) {
528 generalSettings->setConfirmClosingMultipleTabs(false);
529 }
530
531 switch (result) {
532 case KDialog::Yes:
533 // Quit
534 break;
535 case KDialog::No:
536 // Close only the current tab
537 closeTab();
538 default:
539 event->ignore();
540 return;
541 }
542 }
543
544 generalSettings->setFirstRun(false);
545
546 settings.save();
547
548 KXmlGuiWindow::closeEvent(event);
549 }
550
551 void DolphinMainWindow::saveProperties(KConfigGroup& group)
552 {
553 const int tabCount = m_viewTab.count();
554 group.writeEntry("Tab Count", tabCount);
555 group.writeEntry("Active Tab Index", m_tabBar->currentIndex());
556
557 for (int i = 0; i < tabCount; ++i) {
558 const DolphinViewContainer* cont = m_viewTab[i].primaryView;
559 group.writeEntry(tabProperty("Primary URL", i), cont->url().url());
560 group.writeEntry(tabProperty("Primary Editable", i), cont->isUrlEditable());
561
562 cont = m_viewTab[i].secondaryView;
563 if (cont != 0) {
564 group.writeEntry(tabProperty("Secondary URL", i), cont->url().url());
565 group.writeEntry(tabProperty("Secondary Editable", i), cont->isUrlEditable());
566 }
567 }
568 }
569
570 void DolphinMainWindow::readProperties(const KConfigGroup& group)
571 {
572 const int tabCount = group.readEntry("Tab Count", 1);
573 for (int i = 0; i < tabCount; ++i) {
574 DolphinViewContainer* cont = m_viewTab[i].primaryView;
575
576 cont->setUrl(group.readEntry(tabProperty("Primary URL", i)));
577 const bool editable = group.readEntry(tabProperty("Primary Editable", i), false);
578 cont->urlNavigator()->setUrlEditable(editable);
579
580 cont = m_viewTab[i].secondaryView;
581 const QString secondaryUrl = group.readEntry(tabProperty("Secondary URL", i));
582 if (!secondaryUrl.isEmpty()) {
583 if (cont == 0) {
584 // a secondary view should be shown, but no one is available
585 // currently -> create a new view
586 toggleSplitView();
587 cont = m_viewTab[i].secondaryView;
588 Q_ASSERT(cont != 0);
589 }
590
591 cont->setUrl(secondaryUrl);
592 const bool editable = group.readEntry(tabProperty("Secondary Editable", i), false);
593 cont->urlNavigator()->setUrlEditable(editable);
594 } else if (cont != 0) {
595 // no secondary view should be shown, but the default setting shows
596 // one already -> close the view
597 toggleSplitView();
598 }
599
600 // openNewTab() needs to be called only tabCount - 1 times
601 if (i != tabCount - 1) {
602 openNewTab();
603 }
604 }
605
606 const int index = group.readEntry("Active Tab Index", 0);
607 m_tabBar->setCurrentIndex(index);
608 }
609
610 void DolphinMainWindow::updateNewMenu()
611 {
612 m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
613 m_newMenu->slotCheckUpToDate();
614 m_newMenu->setPopupFiles(activeViewContainer()->url());
615 }
616
617 void DolphinMainWindow::createDirectory()
618 {
619 m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
620 m_newMenu->setPopupFiles(activeViewContainer()->url());
621 m_newMenu->createDirectory();
622 }
623
624 void DolphinMainWindow::quit()
625 {
626 close();
627 }
628
629 void DolphinMainWindow::showErrorMessage(const QString& message)
630 {
631 if (!message.isEmpty()) {
632 DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
633 statusBar->setMessage(message, DolphinStatusBar::Error);
634 }
635 }
636
637 void DolphinMainWindow::slotUndoAvailable(bool available)
638 {
639 QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
640 if (undoAction != 0) {
641 undoAction->setEnabled(available);
642 }
643 }
644
645 void DolphinMainWindow::restoreClosedTab(QAction* action)
646 {
647 if (action->data().toBool()) {
648 // clear all actions except the "Empty Recently Closed Tabs"
649 // action and the separator
650 QList<QAction*> actions = m_recentTabsMenu->menu()->actions();
651 const int count = actions.size();
652 for (int i = 2; i < count; ++i) {
653 m_recentTabsMenu->menu()->removeAction(actions.at(i));
654 }
655 } else {
656 const ClosedTab closedTab = action->data().value<ClosedTab>();
657 openNewTab(closedTab.primaryUrl);
658 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
659
660 if (closedTab.isSplit) {
661 // create secondary view
662 toggleSplitView();
663 m_viewTab[m_tabIndex].secondaryView->setUrl(closedTab.secondaryUrl);
664 }
665
666 m_recentTabsMenu->removeAction(action);
667 }
668
669 if (m_recentTabsMenu->menu()->actions().count() == 2) {
670 m_recentTabsMenu->setEnabled(false);
671 }
672 }
673
674 void DolphinMainWindow::slotUndoTextChanged(const QString& text)
675 {
676 QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
677 if (undoAction != 0) {
678 undoAction->setText(text);
679 }
680 }
681
682 void DolphinMainWindow::undo()
683 {
684 clearStatusBar();
685 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
686 KIO::FileUndoManager::self()->undo();
687 }
688
689 void DolphinMainWindow::cut()
690 {
691 m_activeViewContainer->view()->cutSelectedItems();
692 }
693
694 void DolphinMainWindow::copy()
695 {
696 m_activeViewContainer->view()->copySelectedItems();
697 }
698
699 void DolphinMainWindow::paste()
700 {
701 m_activeViewContainer->view()->paste();
702 }
703
704 void DolphinMainWindow::updatePasteAction()
705 {
706 QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
707 QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
708 pasteAction->setEnabled(pasteInfo.first);
709 pasteAction->setText(pasteInfo.second);
710 }
711
712 void DolphinMainWindow::selectAll()
713 {
714 clearStatusBar();
715
716 // if the URL navigator is editable and focused, select the whole
717 // URL instead of all items of the view
718
719 KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
720 QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses
721 const bool selectUrl = urlNavigator->isUrlEditable() &&
722 lineEdit->hasFocus();
723 if (selectUrl) {
724 lineEdit->selectAll();
725 } else {
726 m_activeViewContainer->view()->selectAll();
727 }
728 }
729
730 void DolphinMainWindow::invertSelection()
731 {
732 clearStatusBar();
733 m_activeViewContainer->view()->invertSelection();
734 }
735
736 void DolphinMainWindow::toggleSplitView()
737 {
738 if (m_viewTab[m_tabIndex].secondaryView == 0) {
739 createSecondaryView(m_tabIndex);
740 setActiveViewContainer(m_viewTab[m_tabIndex].secondaryView);
741 } else if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
742 // remove secondary view
743 m_viewTab[m_tabIndex].secondaryView->close();
744 m_viewTab[m_tabIndex].secondaryView->deleteLater();
745 m_viewTab[m_tabIndex].secondaryView = 0;
746
747 setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
748 } else {
749 // The primary view is active and should be closed. Hence from a users point of view
750 // the content of the secondary view should be moved to the primary view.
751 // From an implementation point of view it is more efficient to close
752 // the primary view and exchange the internal pointers afterwards.
753
754 m_viewTab[m_tabIndex].primaryView->close();
755 m_viewTab[m_tabIndex].primaryView->deleteLater();
756 m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
757 m_viewTab[m_tabIndex].secondaryView = 0;
758
759 setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
760 }
761
762 updateViewActions();
763 }
764
765 void DolphinMainWindow::reloadView()
766 {
767 clearStatusBar();
768 m_activeViewContainer->view()->reload();
769 }
770
771 void DolphinMainWindow::stopLoading()
772 {
773 }
774
775 void DolphinMainWindow::toggleFilterBarVisibility(bool show)
776 {
777 m_activeViewContainer->showFilterBar(show);
778 }
779
780 void DolphinMainWindow::toggleEditLocation()
781 {
782 clearStatusBar();
783
784 QAction* action = actionCollection()->action("editable_location");
785 KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
786 urlNavigator->setUrlEditable(action->isChecked());
787 }
788
789 void DolphinMainWindow::replaceLocation()
790 {
791 KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
792 navigator->setUrlEditable(true);
793 navigator->setFocus();
794
795 // select the whole text of the combo box editor
796 QLineEdit* lineEdit = navigator->editor()->lineEdit(); // krazy:exclude=qclasses
797 const QString text = lineEdit->text();
798 lineEdit->setSelection(0, text.length());
799 }
800
801 void DolphinMainWindow::goBack()
802 {
803 clearStatusBar();
804 m_activeViewContainer->urlNavigator()->goBack();
805 }
806
807 void DolphinMainWindow::goForward()
808 {
809 clearStatusBar();
810 m_activeViewContainer->urlNavigator()->goForward();
811 }
812
813 void DolphinMainWindow::goUp()
814 {
815 clearStatusBar();
816 m_activeViewContainer->urlNavigator()->goUp();
817 }
818
819 void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
820 {
821 // The default case (left button pressed) is handled in goBack().
822 if (buttons == Qt::MidButton) {
823 KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
824 openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() + 1));
825 }
826 }
827
828 void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
829 {
830 // The default case (left button pressed) is handled in goForward().
831 if (buttons == Qt::MidButton) {
832 KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
833 openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() - 1));
834 }
835 }
836
837 void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
838 {
839 // The default case (left button pressed) is handled in goUp().
840 if (buttons == Qt::MidButton) {
841 openNewTab(activeViewContainer()->url().upUrl());
842 }
843 }
844
845 void DolphinMainWindow::goHome()
846 {
847 clearStatusBar();
848 m_activeViewContainer->urlNavigator()->goHome();
849 }
850
851 void DolphinMainWindow::compareFiles()
852 {
853 // The method is only invoked if exactly 2 files have
854 // been selected. The selected files may be:
855 // - both in the primary view
856 // - both in the secondary view
857 // - one in the primary view and the other in the secondary
858 // view
859 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
860
861 KUrl urlA;
862 KUrl urlB;
863 KUrl::List urls = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls();
864
865 switch (urls.count()) {
866 case 0: {
867 Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
868 urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
869 Q_ASSERT(urls.count() == 2);
870 urlA = urls[0];
871 urlB = urls[1];
872 break;
873 }
874
875 case 1: {
876 urlA = urls[0];
877 Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
878 urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
879 Q_ASSERT(urls.count() == 1);
880 urlB = urls[0];
881 break;
882 }
883
884 case 2: {
885 urlA = urls[0];
886 urlB = urls[1];
887 break;
888 }
889
890 default: {
891 // may not happen: compareFiles may only get invoked if 2
892 // files are selected
893 Q_ASSERT(false);
894 }
895 }
896
897 QString command("kompare -c \"");
898 command.append(urlA.pathOrUrl());
899 command.append("\" \"");
900 command.append(urlB.pathOrUrl());
901 command.append('\"');
902 KRun::runCommand(command, "Kompare", "kompare", this);
903 }
904
905 void DolphinMainWindow::toggleShowMenuBar()
906 {
907 const bool visible = menuBar()->isVisible();
908 menuBar()->setVisible(!visible);
909 }
910
911 void DolphinMainWindow::openTerminal()
912 {
913 QString dir(QDir::homePath());
914
915 // If the given directory is not local, it can still be the URL of an
916 // ioslave using UDS_LOCAL_PATH which to be converted first.
917 KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
918
919 //If the URL is local after the above conversion, set the directory.
920 if (url.isLocalFile()) {
921 dir = url.toLocalFile();
922 }
923
924 KToolInvocation::invokeTerminal(QString(), dir);
925 }
926
927 void DolphinMainWindow::editSettings()
928 {
929 if (m_settingsDialog == 0) {
930 const KUrl& url = activeViewContainer()->url();
931 m_settingsDialog = new DolphinSettingsDialog(url, this);
932 m_settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
933 m_settingsDialog->show();
934 } else {
935 m_settingsDialog->raise();
936 }
937 }
938
939 void DolphinMainWindow::setActiveTab(int index)
940 {
941 Q_ASSERT(index >= 0);
942 Q_ASSERT(index < m_viewTab.count());
943 if (index == m_tabIndex) {
944 return;
945 }
946
947 // hide current tab content
948 ViewTab& hiddenTab = m_viewTab[m_tabIndex];
949 hiddenTab.isPrimaryViewActive = hiddenTab.primaryView->isActive();
950 hiddenTab.primaryView->setActive(false);
951 if (hiddenTab.secondaryView != 0) {
952 hiddenTab.secondaryView->setActive(false);
953 }
954 QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
955 splitter->hide();
956 m_centralWidgetLayout->removeWidget(splitter);
957
958 // show active tab content
959 m_tabIndex = index;
960
961 ViewTab& viewTab = m_viewTab[index];
962 m_centralWidgetLayout->addWidget(viewTab.splitter, 1);
963 viewTab.primaryView->show();
964 if (viewTab.secondaryView != 0) {
965 viewTab.secondaryView->show();
966 }
967 viewTab.splitter->show();
968
969 setActiveViewContainer(viewTab.isPrimaryViewActive ? viewTab.primaryView :
970 viewTab.secondaryView);
971 }
972
973 void DolphinMainWindow::closeTab()
974 {
975 closeTab(m_tabBar->currentIndex());
976 }
977
978 void DolphinMainWindow::closeTab(int index)
979 {
980 Q_ASSERT(index >= 0);
981 Q_ASSERT(index < m_viewTab.count());
982 if (m_viewTab.count() == 1) {
983 // the last tab may never get closed
984 return;
985 }
986
987 if (index == m_tabIndex) {
988 // The tab that should be closed is the active tab. Activate the
989 // previous tab before closing the tab.
990 m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
991 }
992 rememberClosedTab(index);
993
994 // delete tab
995 m_viewTab[index].primaryView->deleteLater();
996 if (m_viewTab[index].secondaryView != 0) {
997 m_viewTab[index].secondaryView->deleteLater();
998 }
999 m_viewTab[index].splitter->deleteLater();
1000 m_viewTab.erase(m_viewTab.begin() + index);
1001
1002 m_tabBar->blockSignals(true);
1003 m_tabBar->removeTab(index);
1004
1005 if (m_tabIndex > index) {
1006 m_tabIndex--;
1007 Q_ASSERT(m_tabIndex >= 0);
1008 }
1009
1010 // if only one tab is left, also remove the tab entry so that
1011 // closing the last tab is not possible
1012 if (m_viewTab.count() == 1) {
1013 m_tabBar->removeTab(0);
1014 actionCollection()->action("close_tab")->setEnabled(false);
1015 } else {
1016 m_tabBar->blockSignals(false);
1017 }
1018 }
1019
1020 void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
1021 {
1022 KMenu menu(this);
1023
1024 QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
1025 newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
1026
1027 QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
1028
1029 QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
1030 closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
1031 QAction* selectedAction = menu.exec(pos);
1032 if (selectedAction == newTabAction) {
1033 const ViewTab& tab = m_viewTab[index];
1034 Q_ASSERT(tab.primaryView != 0);
1035 const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ?
1036 tab.secondaryView->url() : tab.primaryView->url();
1037 openNewTab(url);
1038 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
1039 } else if (selectedAction == closeOtherTabsAction) {
1040 const int count = m_tabBar->count();
1041 for (int i = 0; i < index; ++i) {
1042 closeTab(0);
1043 }
1044 for (int i = index + 1; i < count; ++i) {
1045 closeTab(1);
1046 }
1047 } else if (selectedAction == closeTabAction) {
1048 closeTab(index);
1049 }
1050 }
1051
1052 void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons)
1053 {
1054 if (buttons & Qt::MidButton) {
1055 openNewTab(url);
1056 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
1057 } else {
1058 changeUrl(url);
1059 }
1060 }
1061
1062 void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& canDecode)
1063 {
1064 canDecode = KUrl::List::canDecode(event->mimeData());
1065 }
1066
1067 void DolphinMainWindow::searchItems()
1068 {
1069 #ifdef HAVE_NEPOMUK
1070 const KUrl nepomukSearchUrl = m_searchOptionsConfigurator->nepomukSearchUrl();
1071 m_activeViewContainer->setUrl(nepomukSearchUrl);
1072 #endif
1073 }
1074
1075 void DolphinMainWindow::slotTabMoved(int from, int to)
1076 {
1077 m_viewTab.move(from, to);
1078 m_tabIndex = m_tabBar->currentIndex();
1079 }
1080
1081 void DolphinMainWindow::showSearchOptions()
1082 {
1083 #ifdef HAVE_NEPOMUK
1084 m_searchOptionsConfigurator->show();
1085 #endif
1086 }
1087
1088 void DolphinMainWindow::init()
1089 {
1090 DolphinSettings& settings = DolphinSettings::instance();
1091
1092 // Check whether Dolphin runs the first time. If yes then
1093 // a proper default window size is given at the end of DolphinMainWindow::init().
1094 GeneralSettings* generalSettings = settings.generalSettings();
1095 const bool firstRun = generalSettings->firstRun();
1096 if (firstRun) {
1097 generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
1098 }
1099
1100 setAcceptDrops(true);
1101
1102 m_viewTab[m_tabIndex].splitter = new QSplitter(this);
1103 m_viewTab[m_tabIndex].splitter->setChildrenCollapsible(false);
1104
1105 setupActions();
1106
1107 const KUrl& homeUrl = generalSettings->homeUrl();
1108 setUrlAsCaption(homeUrl);
1109 m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
1110 connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
1111 connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
1112 ViewProperties props(homeUrl);
1113 m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this,
1114 m_viewTab[m_tabIndex].splitter,
1115 homeUrl);
1116
1117 m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
1118 connectViewSignals(m_activeViewContainer);
1119 DolphinView* view = m_activeViewContainer->view();
1120 view->reload();
1121 m_activeViewContainer->show();
1122 m_actionHandler->setCurrentView(view);
1123
1124 m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
1125 connect(this, SIGNAL(urlChanged(const KUrl&)),
1126 m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
1127
1128 #ifdef HAVE_NEPOMUK
1129 m_searchOptionsConfigurator = new DolphinSearchOptionsConfigurator(this);
1130 m_searchOptionsConfigurator->hide();
1131 connect(m_searchOptionsConfigurator, SIGNAL(searchOptionsChanged()),
1132 this, SLOT(searchItems()));
1133 connect(this, SIGNAL(urlChanged(KUrl)), m_searchOptionsConfigurator, SLOT(setDirectory(KUrl)));
1134 #endif
1135
1136 m_tabBar = new KTabBar(this);
1137 m_tabBar->setMovable(true);
1138 m_tabBar->setTabsClosable(true);
1139 connect(m_tabBar, SIGNAL(currentChanged(int)),
1140 this, SLOT(setActiveTab(int)));
1141 connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
1142 this, SLOT(closeTab(int)));
1143 connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
1144 this, SLOT(openTabContextMenu(int, const QPoint&)));
1145 connect(m_tabBar, SIGNAL(newTabRequest()),
1146 this, SLOT(openNewTab()));
1147 connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
1148 this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
1149 connect(m_tabBar, SIGNAL(wheelDelta(int)),
1150 this, SLOT(slotWheelMoved(int)));
1151 connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
1152 this, SLOT(closeTab(int)));
1153 connect(m_tabBar, SIGNAL(tabMoved(int, int)),
1154 this, SLOT(slotTabMoved(int, int)));
1155
1156 m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
1157
1158 QWidget* centralWidget = new QWidget(this);
1159 m_centralWidgetLayout = new QVBoxLayout(centralWidget);
1160 m_centralWidgetLayout->setSpacing(0);
1161 m_centralWidgetLayout->setMargin(0);
1162 #ifdef HAVE_NEPOMUK
1163 m_centralWidgetLayout->addWidget(m_searchOptionsConfigurator);
1164 #endif
1165 m_centralWidgetLayout->addWidget(m_tabBar);
1166 m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1);
1167
1168 setCentralWidget(centralWidget);
1169 setupDockWidgets();
1170 emit urlChanged(homeUrl);
1171
1172 setupGUI(Keys | Save | Create | ToolBar);
1173
1174 m_searchBox->setParent(toolBar("searchToolBar"));
1175 m_searchBox->show();
1176 connect(m_searchBox, SIGNAL(requestSearchOptions()),
1177 this, SLOT(showSearchOptions()));
1178 #ifdef HAVE_NEPOMUK
1179 connect(m_searchBox, SIGNAL(searchTextChanged(QString)),
1180 m_searchOptionsConfigurator, SLOT(setCustomSearchQuery(QString)));
1181 #endif
1182
1183 stateChanged("new_file");
1184
1185 QClipboard* clipboard = QApplication::clipboard();
1186 connect(clipboard, SIGNAL(dataChanged()),
1187 this, SLOT(updatePasteAction()));
1188 updatePasteAction();
1189 updateGoActions();
1190
1191 if (generalSettings->splitView()) {
1192 toggleSplitView();
1193 }
1194 updateViewActions();
1195
1196 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
1197 showFilterBarAction->setChecked(generalSettings->filterBar());
1198
1199 if (firstRun) {
1200 // assure a proper default size if Dolphin runs the first time
1201 resize(750, 500);
1202 }
1203
1204 m_showMenuBar->setChecked(!menuBar()->isHidden()); // workaround for bug #171080
1205 }
1206
1207 void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
1208 {
1209 Q_ASSERT(viewContainer != 0);
1210 Q_ASSERT((viewContainer == m_viewTab[m_tabIndex].primaryView) ||
1211 (viewContainer == m_viewTab[m_tabIndex].secondaryView));
1212 if (m_activeViewContainer == viewContainer) {
1213 return;
1214 }
1215
1216 m_activeViewContainer->setActive(false);
1217 m_activeViewContainer = viewContainer;
1218
1219 // Activating the view container might trigger a recursive setActiveViewContainer() call
1220 // inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary
1221 // disconnect the activated() signal in this case:
1222 disconnect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
1223 m_activeViewContainer->setActive(true);
1224 connect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
1225
1226 m_actionHandler->setCurrentView(viewContainer->view());
1227
1228 updateHistory();
1229 updateEditActions();
1230 updateViewActions();
1231 updateGoActions();
1232
1233 const KUrl& url = m_activeViewContainer->url();
1234 setUrlAsCaption(url);
1235 if (m_viewTab.count() > 1 && m_viewTab[m_tabIndex].secondaryView != 0) {
1236 m_tabBar->setTabText(m_tabIndex, tabName(url));
1237 m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url)));
1238 }
1239
1240 emit urlChanged(url);
1241 }
1242
1243 void DolphinMainWindow::setupActions()
1244 {
1245 // setup 'File' menu
1246 m_newMenu = new DolphinNewMenu(this, this);
1247 KMenu* menu = m_newMenu->menu();
1248 menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
1249 menu->setIcon(KIcon("document-new"));
1250 connect(menu, SIGNAL(aboutToShow()),
1251 this, SLOT(updateNewMenu()));
1252
1253 KAction* newWindow = actionCollection()->addAction("new_window");
1254 newWindow->setIcon(KIcon("window-new"));
1255 newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
1256 newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
1257 connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
1258
1259 KAction* newTab = actionCollection()->addAction("new_tab");
1260 newTab->setIcon(KIcon("tab-new"));
1261 newTab->setText(i18nc("@action:inmenu File", "New Tab"));
1262 newTab->setShortcut(KShortcut(Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N));
1263 connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
1264
1265 KAction* closeTab = actionCollection()->addAction("close_tab");
1266 closeTab->setIcon(KIcon("tab-close"));
1267 closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
1268 closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
1269 closeTab->setEnabled(false);
1270 connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
1271
1272 KStandardAction::quit(this, SLOT(quit()), actionCollection());
1273
1274 // setup 'Edit' menu
1275 KStandardAction::undo(this,
1276 SLOT(undo()),
1277 actionCollection());
1278
1279 // need to remove shift+del from cut action, else the shortcut for deletejob
1280 // doesn't work
1281 KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
1282 KShortcut cutShortcut = cut->shortcut();
1283 cutShortcut.remove(Qt::SHIFT + Qt::Key_Delete, KShortcut::KeepEmpty);
1284 cut->setShortcut(cutShortcut);
1285 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1286 KAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
1287 // The text of the paste-action is modified dynamically by Dolphin
1288 // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
1289 // due to the long text, the text "Paste" is used:
1290 paste->setIconText(i18nc("@action:inmenu Edit", "Paste"));
1291
1292 KAction* selectAll = actionCollection()->addAction("select_all");
1293 selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
1294 selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
1295 connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
1296
1297 KAction* invertSelection = actionCollection()->addAction("invert_selection");
1298 invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1299 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
1300 connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
1301
1302 // setup 'View' menu
1303 // (note that most of it is set up in DolphinViewActionHandler)
1304
1305 KAction* split = actionCollection()->addAction("split_view");
1306 split->setShortcut(Qt::Key_F3);
1307 updateSplitAction();
1308 connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1309
1310 KAction* reload = actionCollection()->addAction("reload");
1311 reload->setText(i18nc("@action:inmenu View", "Reload"));
1312 reload->setShortcut(Qt::Key_F5);
1313 reload->setIcon(KIcon("view-refresh"));
1314 connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
1315
1316 KAction* stop = actionCollection()->addAction("stop");
1317 stop->setText(i18nc("@action:inmenu View", "Stop"));
1318 stop->setToolTip(i18nc("@info", "Stop loading"));
1319 stop->setIcon(KIcon("process-stop"));
1320 connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
1321
1322 KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
1323 showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1324 showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
1325 connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1326
1327 KAction* replaceLocation = actionCollection()->addAction("replace_location");
1328 replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1329 replaceLocation->setShortcut(Qt::Key_F6);
1330 connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation()));
1331
1332 // setup 'Go' menu
1333 KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
1334 connect(backAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
1335 KShortcut backShortcut = backAction->shortcut();
1336 backShortcut.setAlternate(Qt::Key_Backspace);
1337 backAction->setShortcut(backShortcut);
1338
1339 m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this);
1340 m_recentTabsMenu->setIcon(KIcon("edit-undo"));
1341 actionCollection()->addAction("closed_tabs", m_recentTabsMenu);
1342 connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction *)),
1343 this, SLOT(restoreClosedTab(QAction *)));
1344
1345 QAction* action = new QAction("Empty Recently Closed Tabs", m_recentTabsMenu);
1346 action->setIcon(KIcon("edit-clear-list"));
1347 action->setData(QVariant::fromValue(true));
1348 m_recentTabsMenu->addAction(action);
1349 m_recentTabsMenu->addSeparator();
1350 m_recentTabsMenu->setEnabled(false);
1351
1352 KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1353 connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
1354
1355 KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection());
1356 connect(upAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
1357
1358 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1359
1360 // setup 'Tools' menu
1361 KToggleAction* showSearchBar = actionCollection()->add<KToggleAction>("show_search_bar");
1362 showSearchBar->setText(i18nc("@action:inmenu Tools", "Show Search Bar"));
1363 showSearchBar->setShortcut(Qt::CTRL | Qt::Key_S);
1364 connect(showSearchBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
1365
1366 KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
1367 showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
1368 showFilterBar->setIcon(KIcon("view-filter"));
1369 showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
1370 connect(showFilterBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
1371
1372 KAction* compareFiles = actionCollection()->addAction("compare_files");
1373 compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1374 compareFiles->setIcon(KIcon("kompare"));
1375 compareFiles->setEnabled(false);
1376 connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
1377
1378 KAction* openTerminal = actionCollection()->addAction("open_terminal");
1379 openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
1380 openTerminal->setIcon(KIcon("utilities-terminal"));
1381 openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4);
1382 connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
1383
1384 // setup 'Settings' menu
1385 m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
1386 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1387
1388 // not in menu actions
1389 KAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
1390 activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1391 connect(activateNextTab, SIGNAL(triggered()), SLOT(activateNextTab()));
1392 activateNextTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() :
1393 KStandardShortcut::tabNext());
1394
1395 KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
1396 activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1397 connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab()));
1398 activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() :
1399 KStandardShortcut::tabPrev());
1400
1401 // for context menu
1402 KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab");
1403 openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
1404 openInNewTab->setIcon(KIcon("tab-new"));
1405 connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab()));
1406
1407 KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window");
1408 openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
1409 openInNewWindow->setIcon(KIcon("window-new"));
1410 connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
1411
1412 // 'Search' toolbar
1413 m_searchBox = new DolphinSearchBox(this);
1414 connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(searchItems()));
1415
1416 KAction* search = new KAction(this);
1417 actionCollection()->addAction("search_bar", search);
1418 search->setText(i18nc("@action:inmenu", "Search Bar"));
1419 search->setDefaultWidget(m_searchBox);
1420 search->setShortcutConfigurable(false);
1421 }
1422
1423 void DolphinMainWindow::setupDockWidgets()
1424 {
1425 // setup "Information"
1426 QDockWidget* infoDock = new QDockWidget(i18nc("@title:window", "Information"));
1427 infoDock->setObjectName("infoDock");
1428 infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1429 Panel* infoPanel = new InformationPanel(infoDock);
1430 connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
1431 infoDock->setWidget(infoPanel);
1432
1433 QAction* infoAction = infoDock->toggleViewAction();
1434 infoAction->setText(i18nc("@title:window", "Information"));
1435 infoAction->setShortcut(Qt::Key_F11);
1436 infoAction->setIcon(KIcon("dialog-information"));
1437 actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
1438
1439 addDockWidget(Qt::RightDockWidgetArea, infoDock);
1440 connect(this, SIGNAL(urlChanged(KUrl)),
1441 infoPanel, SLOT(setUrl(KUrl)));
1442 connect(this, SIGNAL(selectionChanged(KFileItemList)),
1443 infoPanel, SLOT(setSelection(KFileItemList)));
1444 connect(this, SIGNAL(requestItemInfo(KFileItem)),
1445 infoPanel, SLOT(requestDelayedItemInfo(KFileItem)));
1446
1447 // setup "Folders"
1448 QDockWidget* foldersDock = new QDockWidget(i18nc("@title:window", "Folders"));
1449 foldersDock->setObjectName("foldersDock");
1450 foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1451 FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
1452 foldersDock->setWidget(foldersPanel);
1453
1454 QAction* foldersAction = foldersDock->toggleViewAction();
1455 foldersAction->setText(i18nc("@title:window", "Folders"));
1456 foldersAction->setShortcut(Qt::Key_F7);
1457 foldersAction->setIcon(KIcon("folder"));
1458 actionCollection()->addAction("show_folders_panel", foldersDock->toggleViewAction());
1459
1460 addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
1461 connect(this, SIGNAL(urlChanged(KUrl)),
1462 foldersPanel, SLOT(setUrl(KUrl)));
1463 connect(foldersPanel, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)),
1464 this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
1465
1466 // setup "Terminal"
1467 #ifndef Q_OS_WIN
1468 QDockWidget* terminalDock = new QDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1469 terminalDock->setObjectName("terminalDock");
1470 terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
1471 Panel* terminalPanel = new TerminalPanel(terminalDock);
1472 terminalDock->setWidget(terminalPanel);
1473
1474 connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide()));
1475
1476 QAction* terminalAction = terminalDock->toggleViewAction();
1477 terminalAction->setText(i18nc("@title:window Shell terminal", "Terminal"));
1478 terminalAction->setShortcut(Qt::Key_F4);
1479 terminalAction->setIcon(KIcon("utilities-terminal"));
1480 actionCollection()->addAction("show_terminal_panel", terminalDock->toggleViewAction());
1481
1482 addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
1483 connect(this, SIGNAL(urlChanged(KUrl)),
1484 terminalPanel, SLOT(setUrl(KUrl)));
1485 #endif
1486
1487 const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
1488 if (firstRun) {
1489 foldersDock->hide();
1490 #ifndef Q_OS_WIN
1491 terminalDock->hide();
1492 #endif
1493 }
1494
1495 QDockWidget* placesDock = new QDockWidget(i18nc("@title:window", "Places"));
1496 placesDock->setObjectName("placesDock");
1497 placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1498
1499 PlacesPanel* placesPanel = new PlacesPanel(placesDock);
1500 placesDock->setWidget(placesPanel);
1501 placesPanel->setModel(DolphinSettings::instance().placesModel());
1502 placesPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1503
1504 QAction* placesAction = placesDock->toggleViewAction();
1505 placesAction->setText(i18nc("@title:window", "Places"));
1506 placesAction->setShortcut(Qt::Key_F9);
1507 placesAction->setIcon(KIcon("bookmarks"));
1508 actionCollection()->addAction("show_places_panel", placesDock->toggleViewAction());
1509
1510 addDockWidget(Qt::LeftDockWidgetArea, placesDock);
1511 connect(placesPanel, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)),
1512 this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
1513 connect(this, SIGNAL(urlChanged(KUrl)),
1514 placesPanel, SLOT(setUrl(KUrl)));
1515 }
1516
1517 void DolphinMainWindow::updateEditActions()
1518 {
1519 const KFileItemList list = m_activeViewContainer->view()->selectedItems();
1520 if (list.isEmpty()) {
1521 stateChanged("has_no_selection");
1522 } else {
1523 stateChanged("has_selection");
1524
1525 KActionCollection* col = actionCollection();
1526 QAction* renameAction = col->action("rename");
1527 QAction* moveToTrashAction = col->action("move_to_trash");
1528 QAction* deleteAction = col->action("delete");
1529 QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
1530 QAction* deleteWithTrashShortcut = col->action("delete_shortcut"); // see DolphinViewActionHandler
1531
1532 KFileItemListProperties capabilities(list);
1533 const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
1534
1535 renameAction->setEnabled(capabilities.supportsMoving());
1536 moveToTrashAction->setEnabled(enableMoveToTrash);
1537 deleteAction->setEnabled(capabilities.supportsDeleting());
1538 deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
1539 cutAction->setEnabled(capabilities.supportsMoving());
1540 }
1541 updatePasteAction();
1542 }
1543
1544 void DolphinMainWindow::updateViewActions()
1545 {
1546 m_actionHandler->updateViewActions();
1547
1548 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
1549 showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
1550
1551 updateSplitAction();
1552
1553 QAction* editableLocactionAction = actionCollection()->action("editable_location");
1554 const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
1555 editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
1556 }
1557
1558 void DolphinMainWindow::updateGoActions()
1559 {
1560 QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
1561 const KUrl& currentUrl = m_activeViewContainer->url();
1562 goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
1563 }
1564
1565 void DolphinMainWindow::rememberClosedTab(int index)
1566 {
1567 KMenu* tabsMenu = m_recentTabsMenu->menu();
1568
1569 const QString primaryPath = m_viewTab[index].primaryView->url().path();
1570 const QString iconName = KMimeType::iconNameForUrl(primaryPath);
1571
1572 QAction* action = new QAction(squeezedText(primaryPath), tabsMenu);
1573
1574 ClosedTab closedTab;
1575 closedTab.primaryUrl = m_viewTab[index].primaryView->url();
1576
1577 if (m_viewTab[index].secondaryView != 0) {
1578 closedTab.secondaryUrl = m_viewTab[index].secondaryView->url();
1579 closedTab.isSplit = true;
1580 } else {
1581 closedTab.isSplit = false;
1582 }
1583
1584 action->setData(QVariant::fromValue(closedTab));
1585 action->setIcon(KIcon(iconName));
1586
1587 // add the closed tab menu entry after the separator and
1588 // "Empty Recently Closed Tabs" entry
1589 if (tabsMenu->actions().size() == 2) {
1590 tabsMenu->addAction(action);
1591 } else {
1592 tabsMenu->insertAction(tabsMenu->actions().at(2), action);
1593 }
1594
1595 // assure that only up to 8 closed tabs are shown in the menu
1596 if (tabsMenu->actions().size() > 8) {
1597 tabsMenu->removeAction(tabsMenu->actions().last());
1598 }
1599 actionCollection()->action("closed_tabs")->setEnabled(true);
1600 KAcceleratorManager::manage(tabsMenu);
1601 }
1602
1603 void DolphinMainWindow::clearStatusBar()
1604 {
1605 m_activeViewContainer->statusBar()->clear();
1606 }
1607
1608 void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
1609 {
1610 connect(container, SIGNAL(showFilterBarChanged(bool)),
1611 this, SLOT(updateFilterBarAction(bool)));
1612
1613 DolphinView* view = container->view();
1614 connect(view, SIGNAL(selectionChanged(KFileItemList)),
1615 this, SLOT(slotSelectionChanged(KFileItemList)));
1616 connect(view, SIGNAL(requestItemInfo(KFileItem)),
1617 this, SLOT(slotRequestItemInfo(KFileItem)));
1618 connect(view, SIGNAL(activated()),
1619 this, SLOT(toggleActiveView()));
1620 connect(view, SIGNAL(tabRequested(const KUrl&)),
1621 this, SLOT(openNewTab(const KUrl&)));
1622
1623 const KUrlNavigator* navigator = container->urlNavigator();
1624 connect(navigator, SIGNAL(urlChanged(const KUrl&)),
1625 this, SLOT(changeUrl(const KUrl&)));
1626 connect(navigator, SIGNAL(historyChanged()),
1627 this, SLOT(updateHistory()));
1628 connect(navigator, SIGNAL(editableStateChanged(bool)),
1629 this, SLOT(slotEditableStateChanged(bool)));
1630 }
1631
1632 void DolphinMainWindow::updateSplitAction()
1633 {
1634 QAction* splitAction = actionCollection()->action("split_view");
1635 if (m_viewTab[m_tabIndex].secondaryView != 0) {
1636 if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
1637 splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
1638 splitAction->setToolTip(i18nc("@info", "Close right view"));
1639 splitAction->setIcon(KIcon("view-right-close"));
1640 } else {
1641 splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
1642 splitAction->setToolTip(i18nc("@info", "Close left view"));
1643 splitAction->setIcon(KIcon("view-left-close"));
1644 }
1645 } else {
1646 splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
1647 splitAction->setToolTip(i18nc("@info", "Split view"));
1648 splitAction->setIcon(KIcon("view-right-new"));
1649 }
1650 }
1651
1652 QString DolphinMainWindow::tabName(const KUrl& url) const
1653 {
1654 QString name;
1655 if (url.equals(KUrl("file:///"))) {
1656 name = '/';
1657 } else {
1658 name = url.fileName();
1659 if (name.isEmpty()) {
1660 name = url.protocol();
1661 } else {
1662 // Make sure that a '&' inside the directory name is displayed correctly
1663 // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
1664 name.replace('&', "&&");
1665 }
1666 }
1667 return name;
1668 }
1669
1670 bool DolphinMainWindow::isKompareInstalled() const
1671 {
1672 static bool initialized = false;
1673 static bool installed = false;
1674 if (!initialized) {
1675 // TODO: maybe replace this approach later by using a menu
1676 // plugin like kdiff3plugin.cpp
1677 installed = !KGlobal::dirs()->findExe("kompare").isEmpty();
1678 initialized = true;
1679 }
1680 return installed;
1681 }
1682
1683 void DolphinMainWindow::createSecondaryView(int tabIndex)
1684 {
1685 QSplitter* splitter = m_viewTab[tabIndex].splitter;
1686 const int newWidth = (m_viewTab[tabIndex].primaryView->width() - splitter->handleWidth()) / 2;
1687
1688 const DolphinView* view = m_viewTab[tabIndex].primaryView->view();
1689 m_viewTab[tabIndex].secondaryView = new DolphinViewContainer(this, 0, view->rootUrl());
1690 splitter->addWidget(m_viewTab[tabIndex].secondaryView);
1691 splitter->setSizes(QList<int>() << newWidth << newWidth);
1692 connectViewSignals(m_viewTab[tabIndex].secondaryView);
1693 m_viewTab[tabIndex].secondaryView->view()->reload();
1694 m_viewTab[tabIndex].secondaryView->setActive(false);
1695 m_viewTab[tabIndex].secondaryView->show();
1696 }
1697
1698 QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) const
1699 {
1700 return "Tab " + QString::number(tabIndex) + ' ' + property;
1701 }
1702
1703 void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
1704 {
1705 QString caption;
1706 if (url.equals(KUrl("file:///"))) {
1707 caption = '/';
1708 } else {
1709 caption = url.fileName();
1710 if (caption.isEmpty()) {
1711 caption = url.protocol();
1712 }
1713 }
1714
1715 setCaption(caption);
1716 }
1717
1718 void DolphinMainWindow::handleUrl(const KUrl& url)
1719 {
1720 if (KProtocolManager::supportsListing(url)) {
1721 activeViewContainer()->setUrl(url);
1722 }
1723 else {
1724 new KRun(url, this);
1725 }
1726 }
1727
1728 QString DolphinMainWindow::squeezedText(const QString& text) const
1729 {
1730 const QFontMetrics fm = fontMetrics();
1731 return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10);
1732 }
1733
1734 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
1735 KIO::FileUndoManager::UiInterface()
1736 {
1737 }
1738
1739 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1740 {
1741 }
1742
1743 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
1744 {
1745 DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
1746 if (mainWin) {
1747 DolphinStatusBar* statusBar = mainWin->activeViewContainer()->statusBar();
1748 statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
1749 } else {
1750 KIO::FileUndoManager::UiInterface::jobError(job);
1751 }
1752 }
1753
1754 #include "dolphinmainwindow.moc"