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