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