]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
95108724ee4b520e23c8447411c8d83b74d6d5a6
[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 "dolphindropcontroller.h"
25
26 #include <config-nepomuk.h>
27
28 #include "dolphinapplication.h"
29 #include "dolphinfileplacesview.h"
30 #include "dolphinnewmenu.h"
31 #include "dolphinsettings.h"
32 #include "dolphinsettingsdialog.h"
33 #include "dolphinstatusbar.h"
34 #include "dolphinviewcontainer.h"
35 #include "infosidebarpage.h"
36 #include "metadatawidget.h"
37 #include "mainwindowadaptor.h"
38 #include "treeviewsidebarpage.h"
39 #include "viewproperties.h"
40
41 #ifndef Q_OS_WIN
42 #include "terminalsidebarpage.h"
43 #endif
44
45 #include "dolphin_generalsettings.h"
46 #include "dolphin_iconsmodesettings.h"
47
48 #include <kaction.h>
49 #include <kactioncollection.h>
50 #include <kconfig.h>
51 #include <kdesktopfile.h>
52 #include <kdeversion.h>
53 #include <kfiledialog.h>
54 #include <kfileplacesmodel.h>
55 #include <kglobal.h>
56 #include <kicon.h>
57 #include <kiconloader.h>
58 #include <kio/netaccess.h>
59 #include <kinputdialog.h>
60 #include <klocale.h>
61 #include <kmenu.h>
62 #include <kmenubar.h>
63 #include <kmessagebox.h>
64 #include <konq_fileitemcapabilities.h>
65 #include <konqmimedata.h>
66 #include <kprotocolinfo.h>
67 #include <krun.h>
68 #include <kshell.h>
69 #include <kstandarddirs.h>
70 #include <kstatusbar.h>
71 #include <kstandardaction.h>
72 #include <ktabbar.h>
73 #include <ktoggleaction.h>
74 #include <kurlnavigator.h>
75 #include <kurl.h>
76 #include <kurlcombobox.h>
77
78 #include <QKeyEvent>
79 #include <QClipboard>
80 #include <QLineEdit>
81 #include <QSplitter>
82 #include <QDockWidget>
83
84 DolphinMainWindow::DolphinMainWindow(int id) :
85 KXmlGuiWindow(0),
86 m_newMenu(0),
87 m_showMenuBar(0),
88 m_tabBar(0),
89 m_activeViewContainer(0),
90 m_centralWidgetLayout(0),
91 m_id(id),
92 m_tabIndex(0),
93 m_viewTab(),
94 m_actionHandler(0)
95 {
96 setObjectName("Dolphin#");
97
98 m_viewTab.append(ViewTab());
99
100 new MainWindowAdaptor(this);
101 QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);
102
103 KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
104 undoManager->setUiInterface(new UndoUiInterface());
105
106 connect(undoManager, SIGNAL(undoAvailable(bool)),
107 this, SLOT(slotUndoAvailable(bool)));
108 connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
109 this, SLOT(slotUndoTextChanged(const QString&)));
110 connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)),
111 this, SLOT(slotHandlePlacesError(const QString&)));
112 }
113
114 DolphinMainWindow::~DolphinMainWindow()
115 {
116 DolphinApplication::app()->removeMainWindow(this);
117 }
118
119 void DolphinMainWindow::toggleViews()
120 {
121 if (m_viewTab[m_tabIndex].primaryView == 0) {
122 return;
123 }
124
125 // move secondary view from the last position of the splitter
126 // to the first position
127 m_viewTab[m_tabIndex].splitter->insertWidget(0, m_viewTab[m_tabIndex].secondaryView);
128
129 DolphinViewContainer* container = m_viewTab[m_tabIndex].primaryView;
130 m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
131 m_viewTab[m_tabIndex].secondaryView = container;
132 }
133
134 void DolphinMainWindow::slotDoingOperation(KIO::FileUndoManager::CommandType commandType)
135 {
136 clearStatusBar();
137 m_undoCommandTypes.append(commandType);
138 }
139
140 void DolphinMainWindow::refreshViews()
141 {
142 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
143
144 // remember the current active view, as because of
145 // the refreshing the active view might change to
146 // the secondary view
147 DolphinViewContainer* activeViewContainer = m_activeViewContainer;
148
149 m_viewTab[m_tabIndex].primaryView->view()->refresh();
150 if (m_viewTab[m_tabIndex].secondaryView != 0) {
151 m_viewTab[m_tabIndex].secondaryView->view()->refresh();
152 }
153
154 setActiveViewContainer(activeViewContainer);
155 }
156
157 void DolphinMainWindow::dropUrls(const KUrl::List& urls,
158 const KUrl& destination)
159 {
160 DolphinDropController dropController(this);
161 connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
162 this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
163 dropController.dropUrls(urls, destination);
164 }
165
166 void DolphinMainWindow::pasteIntoFolder()
167 {
168 m_activeViewContainer->view()->pasteIntoFolder();
169 }
170
171 void DolphinMainWindow::changeUrl(const KUrl& url)
172 {
173 DolphinViewContainer* view = activeViewContainer();
174 if (view != 0) {
175 view->setUrl(url);
176 updateEditActions();
177 updateViewActions();
178 updateGoActions();
179 setCaption(url.fileName());
180 if (m_viewTab.count() > 1) {
181 m_tabBar->setTabText(m_tabIndex, tabName(url));
182 }
183 emit urlChanged(url);
184 }
185 }
186
187 void DolphinMainWindow::changeSelection(const KFileItemList& selection)
188 {
189 activeViewContainer()->view()->changeSelection(selection);
190 }
191
192 void DolphinMainWindow::slotEditableStateChanged(bool editable)
193 {
194 KToggleAction* editableLocationAction =
195 static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
196 editableLocationAction->setChecked(editable);
197 }
198
199 void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
200 {
201 updateEditActions();
202
203 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
204 int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls().count();
205 if (m_viewTab[m_tabIndex].secondaryView != 0) {
206 selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls().count();
207 }
208
209 QAction* compareFilesAction = actionCollection()->action("compare_files");
210 if (selectedUrlsCount == 2) {
211 compareFilesAction->setEnabled(isKompareInstalled());
212 } else {
213 compareFilesAction->setEnabled(false);
214 }
215
216 m_activeViewContainer->updateStatusBar();
217
218 emit selectionChanged(selection);
219 }
220
221 void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
222 {
223 emit requestItemInfo(item);
224 }
225
226 void DolphinMainWindow::updateHistory()
227 {
228 const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
229 const int index = urlNavigator->historyIndex();
230
231 QAction* backAction = actionCollection()->action("go_back");
232 if (backAction != 0) {
233 backAction->setEnabled(index < urlNavigator->historySize() - 1);
234 }
235
236 QAction* forwardAction = actionCollection()->action("go_forward");
237 if (forwardAction != 0) {
238 forwardAction->setEnabled(index > 0);
239 }
240 }
241
242 void DolphinMainWindow::updateFilterBarAction(bool show)
243 {
244 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
245 showFilterBarAction->setChecked(show);
246 }
247
248 void DolphinMainWindow::openNewMainWindow()
249 {
250 DolphinApplication::app()->createMainWindow()->show();
251 }
252
253 void DolphinMainWindow::openNewTab()
254 {
255 openNewTab(m_activeViewContainer->url());
256 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
257 }
258
259 void DolphinMainWindow::openNewTab(const KUrl& url)
260 {
261 if (m_viewTab.count() == 1) {
262 // Only one view is open currently and hence no tab is shown at
263 // all. Before creating a tab for 'url', provide a tab for the current URL.
264 m_tabBar->addTab(KIcon("folder"), tabName(m_activeViewContainer->url()));
265 m_tabBar->blockSignals(false);
266 }
267
268 m_tabBar->addTab(KIcon("folder"), tabName(url));
269
270 ViewTab viewTab;
271 viewTab.splitter = new QSplitter(this);
272 viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
273 connectViewSignals(viewTab.primaryView);
274 viewTab.primaryView->view()->reload();
275
276 m_viewTab.append(viewTab);
277 }
278
279 void DolphinMainWindow::toggleActiveView()
280 {
281 if (m_viewTab[m_tabIndex].secondaryView == 0) {
282 // only one view is available
283 return;
284 }
285
286 Q_ASSERT(m_activeViewContainer != 0);
287 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
288
289 DolphinViewContainer* left = m_viewTab[m_tabIndex].primaryView;
290 DolphinViewContainer* right = m_viewTab[m_tabIndex].secondaryView;
291 setActiveViewContainer(m_activeViewContainer == right ? left : right);
292 }
293
294 void DolphinMainWindow::closeEvent(QCloseEvent* event)
295 {
296 DolphinSettings& settings = DolphinSettings::instance();
297 GeneralSettings* generalSettings = settings.generalSettings();
298 generalSettings->setFirstRun(false);
299
300 settings.save();
301
302 KXmlGuiWindow::closeEvent(event);
303 }
304
305 void DolphinMainWindow::saveProperties(KConfigGroup& group)
306 {
307 // TODO: remember tabs
308 DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
309 group.writeEntry("Primary Url", cont->url().url());
310 group.writeEntry("Primary Editable Url", cont->isUrlEditable());
311
312 cont = m_viewTab[m_tabIndex].secondaryView;
313 if (cont != 0) {
314 group.writeEntry("Secondary Url", cont->url().url());
315 group.writeEntry("Secondary Editable Url", cont->isUrlEditable());
316 }
317 }
318
319 void DolphinMainWindow::readProperties(const KConfigGroup& group)
320 {
321 // TODO: read tabs
322 DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
323
324 cont->setUrl(group.readEntry("Primary Url"));
325 bool editable = group.readEntry("Primary Editable Url", false);
326 cont->urlNavigator()->setUrlEditable(editable);
327
328 cont = m_viewTab[m_tabIndex].secondaryView;
329 const QString secondaryUrl = group.readEntry("Secondary Url");
330 if (!secondaryUrl.isEmpty()) {
331 if (cont == 0) {
332 // a secondary view should be shown, but no one is available
333 // currently -> create a new view
334 toggleSplitView();
335 cont = m_viewTab[m_tabIndex].secondaryView;
336 Q_ASSERT(cont != 0);
337 }
338
339 cont->setUrl(secondaryUrl);
340 bool editable = group.readEntry("Secondary Editable Url", false);
341 cont->urlNavigator()->setUrlEditable(editable);
342 } else if (cont != 0) {
343 // no secondary view should be shown, but the default setting shows
344 // one already -> close the view
345 toggleSplitView();
346 }
347 }
348
349 void DolphinMainWindow::updateNewMenu()
350 {
351 m_newMenu->slotCheckUpToDate();
352 m_newMenu->setPopupFiles(activeViewContainer()->url());
353 }
354
355 void DolphinMainWindow::quit()
356 {
357 close();
358 }
359
360 void DolphinMainWindow::slotHandlePlacesError(const QString &message)
361 {
362 if (!message.isEmpty()) {
363 DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
364 statusBar->setMessage(message, DolphinStatusBar::Error);
365 }
366 }
367
368 void DolphinMainWindow::slotUndoAvailable(bool available)
369 {
370 QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
371 if (undoAction != 0) {
372 undoAction->setEnabled(available);
373 }
374
375 if (available && (m_undoCommandTypes.count() > 0)) {
376 const KIO::FileUndoManager::CommandType command = m_undoCommandTypes.takeFirst();
377 DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
378 switch (command) {
379 case KIO::FileUndoManager::Copy:
380 statusBar->setMessage(i18nc("@info:status", "Copy operation completed."),
381 DolphinStatusBar::OperationCompleted);
382 break;
383 case KIO::FileUndoManager::Move:
384 statusBar->setMessage(i18nc("@info:status", "Move operation completed."),
385 DolphinStatusBar::OperationCompleted);
386 break;
387 case KIO::FileUndoManager::Link:
388 statusBar->setMessage(i18nc("@info:status", "Link operation completed."),
389 DolphinStatusBar::OperationCompleted);
390 break;
391 case KIO::FileUndoManager::Trash:
392 statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."),
393 DolphinStatusBar::OperationCompleted);
394 break;
395 case KIO::FileUndoManager::Rename:
396 statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."),
397 DolphinStatusBar::OperationCompleted);
398 break;
399
400 case KIO::FileUndoManager::Mkdir:
401 statusBar->setMessage(i18nc("@info:status", "Created folder."),
402 DolphinStatusBar::OperationCompleted);
403 break;
404
405 default:
406 break;
407 }
408
409 }
410 }
411
412 void DolphinMainWindow::slotUndoTextChanged(const QString& text)
413 {
414 QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
415 if (undoAction != 0) {
416 undoAction->setText(text);
417 }
418 }
419
420 void DolphinMainWindow::undo()
421 {
422 clearStatusBar();
423 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
424 KIO::FileUndoManager::self()->undo();
425 }
426
427 void DolphinMainWindow::cut()
428 {
429 m_activeViewContainer->view()->cutSelectedItems();
430 }
431
432 void DolphinMainWindow::copy()
433 {
434 m_activeViewContainer->view()->copySelectedItems();
435 }
436
437 void DolphinMainWindow::paste()
438 {
439 m_activeViewContainer->view()->paste();
440 }
441
442 void DolphinMainWindow::updatePasteAction()
443 {
444 QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
445 QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
446 pasteAction->setEnabled(pasteInfo.first);
447 pasteAction->setText(pasteInfo.second);
448 }
449
450 void DolphinMainWindow::selectAll()
451 {
452 clearStatusBar();
453
454 // if the URL navigator is editable and focused, select the whole
455 // URL instead of all items of the view
456
457 KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
458 QLineEdit* lineEdit = urlNavigator->editor()->lineEdit();
459 const bool selectUrl = urlNavigator->isUrlEditable() &&
460 lineEdit->hasFocus();
461 if (selectUrl) {
462 lineEdit->selectAll();
463 } else {
464 m_activeViewContainer->view()->selectAll();
465 }
466 }
467
468 void DolphinMainWindow::invertSelection()
469 {
470 clearStatusBar();
471 m_activeViewContainer->view()->invertSelection();
472 }
473
474 void DolphinMainWindow::toggleSplitView()
475 {
476 if (m_viewTab[m_tabIndex].secondaryView == 0) {
477 // create a secondary view
478 QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
479 const int newWidth = (m_viewTab[m_tabIndex].primaryView->width() - splitter->handleWidth()) / 2;
480
481 const DolphinView* view = m_viewTab[m_tabIndex].primaryView->view();
482 m_viewTab[m_tabIndex].secondaryView = new DolphinViewContainer(this, 0, view->rootUrl());
483 connectViewSignals(m_viewTab[m_tabIndex].secondaryView);
484 splitter->addWidget(m_viewTab[m_tabIndex].secondaryView);
485 splitter->setSizes(QList<int>() << newWidth << newWidth);
486 m_viewTab[m_tabIndex].secondaryView->view()->reload();
487 m_viewTab[m_tabIndex].secondaryView->setActive(false);
488 m_viewTab[m_tabIndex].secondaryView->show();
489
490 setActiveViewContainer(m_viewTab[m_tabIndex].secondaryView);
491 } else if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
492 // remove secondary view
493 m_viewTab[m_tabIndex].secondaryView->close();
494 m_viewTab[m_tabIndex].secondaryView->deleteLater();
495 m_viewTab[m_tabIndex].secondaryView = 0;
496
497 setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
498 } else {
499 // The primary view is active and should be closed. Hence from a users point of view
500 // the content of the secondary view should be moved to the primary view.
501 // From an implementation point of view it is more efficient to close
502 // the primary view and exchange the internal pointers afterwards.
503
504 m_viewTab[m_tabIndex].primaryView->close();
505 m_viewTab[m_tabIndex].primaryView->deleteLater();
506 m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
507 m_viewTab[m_tabIndex].secondaryView = 0;
508
509 setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
510 }
511
512 updateViewActions();
513 }
514
515 void DolphinMainWindow::reloadView()
516 {
517 clearStatusBar();
518 m_activeViewContainer->view()->reload();
519 }
520
521 void DolphinMainWindow::stopLoading()
522 {
523 }
524
525 void DolphinMainWindow::toggleFilterBarVisibility(bool show)
526 {
527 m_activeViewContainer->showFilterBar(show);
528 }
529
530 void DolphinMainWindow::toggleEditLocation()
531 {
532 clearStatusBar();
533
534 QAction* action = actionCollection()->action("editable_location");
535 KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
536 urlNavigator->setUrlEditable(action->isChecked());
537 }
538
539 void DolphinMainWindow::editLocation()
540 {
541 KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
542 navigator->setUrlEditable(true);
543 navigator->setFocus();
544
545 // select the whole text of the combo box editor
546 QLineEdit* lineEdit = navigator->editor()->lineEdit();
547 const QString text = lineEdit->text();
548 lineEdit->setSelection(0, text.length());
549 }
550
551 void DolphinMainWindow::goBack()
552 {
553 clearStatusBar();
554 m_activeViewContainer->urlNavigator()->goBack();
555 }
556
557 void DolphinMainWindow::goForward()
558 {
559 clearStatusBar();
560 m_activeViewContainer->urlNavigator()->goForward();
561 }
562
563 void DolphinMainWindow::goUp()
564 {
565 clearStatusBar();
566 m_activeViewContainer->urlNavigator()->goUp();
567 }
568
569 void DolphinMainWindow::goHome()
570 {
571 clearStatusBar();
572 m_activeViewContainer->urlNavigator()->goHome();
573 }
574
575 void DolphinMainWindow::compareFiles()
576 {
577 // The method is only invoked if exactly 2 files have
578 // been selected. The selected files may be:
579 // - both in the primary view
580 // - both in the secondary view
581 // - one in the primary view and the other in the secondary
582 // view
583 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
584
585 KUrl urlA;
586 KUrl urlB;
587 KUrl::List urls = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls();
588
589 switch (urls.count()) {
590 case 0: {
591 Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
592 urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
593 Q_ASSERT(urls.count() == 2);
594 urlA = urls[0];
595 urlB = urls[1];
596 break;
597 }
598
599 case 1: {
600 urlA = urls[0];
601 Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
602 urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
603 Q_ASSERT(urls.count() == 1);
604 urlB = urls[0];
605 break;
606 }
607
608 case 2: {
609 urlA = urls[0];
610 urlB = urls[1];
611 break;
612 }
613
614 default: {
615 // may not happen: compareFiles may only get invoked if 2
616 // files are selected
617 Q_ASSERT(false);
618 }
619 }
620
621 QString command("kompare -c \"");
622 command.append(urlA.pathOrUrl());
623 command.append("\" \"");
624 command.append(urlB.pathOrUrl());
625 command.append('\"');
626 KRun::runCommand(command, "Kompare", "kompare", this);
627 }
628
629 void DolphinMainWindow::toggleShowMenuBar()
630 {
631 const bool visible = menuBar()->isVisible();
632 menuBar()->setVisible(!visible);
633 }
634
635 void DolphinMainWindow::editSettings()
636 {
637 DolphinSettingsDialog dialog(this);
638 dialog.exec();
639 }
640
641 void DolphinMainWindow::setActiveTab(int index)
642 {
643 Q_ASSERT(index >= 0);
644 Q_ASSERT(index < m_viewTab.count());
645 if (index == m_tabIndex) {
646 return;
647 }
648
649 // hide current tab content
650 m_viewTab[m_tabIndex].isPrimaryViewActive = m_viewTab[m_tabIndex].primaryView->isActive();
651 QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
652 splitter->hide();
653 m_centralWidgetLayout->removeWidget(splitter);
654
655 // show active tab content
656 m_tabIndex = index;
657
658 ViewTab& viewTab = m_viewTab[index];
659 m_centralWidgetLayout->addWidget(viewTab.splitter);
660 viewTab.primaryView->show();
661 if (viewTab.secondaryView != 0) {
662 viewTab.secondaryView->show();
663 }
664 viewTab.splitter->show();
665
666 setActiveViewContainer(viewTab.isPrimaryViewActive ? viewTab.primaryView :
667 viewTab.secondaryView);
668 }
669
670 void DolphinMainWindow::closeTab()
671 {
672 closeTab(m_tabBar->currentIndex());
673 }
674
675 void DolphinMainWindow::closeTab(int index)
676 {
677 Q_ASSERT(index >= 0);
678 Q_ASSERT(index < m_viewTab.count());
679 if (m_viewTab.count() == 1) {
680 // the last tab may never get closed
681 return;
682 }
683
684 if (index == m_tabIndex) {
685 // The tab that should be closed is the active tab. Activate the
686 // previous tab before closing the tab.
687 setActiveTab((index > 0) ? index - 1 : 1);
688 }
689
690 // delete tab
691 m_viewTab[index].primaryView->deleteLater();
692 if (m_viewTab[index].secondaryView != 0) {
693 m_viewTab[index].secondaryView->deleteLater();
694 }
695 m_viewTab[index].splitter->deleteLater();
696 m_viewTab.erase(m_viewTab.begin() + index);
697
698 m_tabBar->blockSignals(true);
699 m_tabBar->removeTab(index);
700
701 if (m_tabIndex > index) {
702 m_tabIndex--;
703 Q_ASSERT(m_tabIndex >= 0);
704 }
705
706 // if only one tab is left, also remove the tab entry so that
707 // closing the last tab is not possible
708 if (m_viewTab.count() == 1) {
709 m_tabBar->removeTab(0);
710 } else {
711 m_tabBar->blockSignals(false);
712 }
713 }
714
715 void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
716 {
717 KMenu menu(this);
718
719 QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
720 newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
721
722 QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
723
724 QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
725 closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
726
727 QAction* selectedAction = menu.exec(pos);
728 if (selectedAction == newTabAction) {
729 const ViewTab& tab = m_viewTab[index];
730 Q_ASSERT(tab.primaryView != 0);
731 const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ?
732 tab.secondaryView->url() : tab.primaryView->url();
733 openNewTab(url);
734 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
735 } else if (selectedAction == closeOtherTabsAction) {
736 const int count = m_tabBar->count();
737 for (int i = 0; i < index; ++i) {
738 closeTab(0);
739 }
740 for (int i = index + 1; i < count; ++i) {
741 closeTab(1);
742 }
743 } else if (selectedAction == closeTabAction) {
744 closeTab(index);
745 }
746 }
747
748 void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons)
749 {
750 if (buttons & Qt::MidButton) {
751 openNewTab(url);
752 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
753 } else {
754 changeUrl(url);
755 }
756 }
757
758 void DolphinMainWindow::init()
759 {
760 DolphinSettings& settings = DolphinSettings::instance();
761
762 // Check whether Dolphin runs the first time. If yes then
763 // a proper default window size is given at the end of DolphinMainWindow::init().
764 GeneralSettings* generalSettings = settings.generalSettings();
765 const bool firstRun = generalSettings->firstRun();
766 if (firstRun) {
767 generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
768 }
769
770 setAcceptDrops(true);
771
772 m_viewTab[m_tabIndex].splitter = new QSplitter(this);
773
774 setupActions();
775
776 const KUrl& homeUrl = generalSettings->homeUrl();
777 setCaption(homeUrl.fileName());
778 m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
779 connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
780 ViewProperties props(homeUrl);
781 m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this,
782 m_viewTab[m_tabIndex].splitter,
783 homeUrl);
784
785 m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
786 connectViewSignals(m_activeViewContainer);
787 DolphinView* view = m_activeViewContainer->view();
788 view->reload();
789 m_activeViewContainer->show();
790 m_actionHandler->setCurrentView(view);
791
792 m_tabBar = new KTabBar(this);
793 m_tabBar->setCloseButtonEnabled(true);
794 connect(m_tabBar, SIGNAL(currentChanged(int)),
795 this, SLOT(setActiveTab(int)));
796 connect(m_tabBar, SIGNAL(closeRequest(int)),
797 this, SLOT(closeTab(int)));
798 connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
799 this, SLOT(openTabContextMenu(int, const QPoint&)));
800 connect(m_tabBar, SIGNAL(newTabRequest()),
801 this, SLOT(openNewTab()));
802 m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
803
804 QWidget* centralWidget = new QWidget(this);
805 m_centralWidgetLayout = new QVBoxLayout(centralWidget);
806 m_centralWidgetLayout->setSpacing(0);
807 m_centralWidgetLayout->setMargin(0);
808 m_centralWidgetLayout->addWidget(m_tabBar);
809 m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter);
810
811
812 setCentralWidget(centralWidget);
813 setupDockWidgets();
814
815 setupGUI(Keys | Save | Create | ToolBar);
816 createGUI();
817
818 stateChanged("new_file");
819 setAutoSaveSettings();
820
821 QClipboard* clipboard = QApplication::clipboard();
822 connect(clipboard, SIGNAL(dataChanged()),
823 this, SLOT(updatePasteAction()));
824 updatePasteAction();
825 updateGoActions();
826
827 if (generalSettings->splitView()) {
828 toggleSplitView();
829 }
830 updateViewActions();
831
832 if (firstRun) {
833 // assure a proper default size if Dolphin runs the first time
834 resize(750, 500);
835 }
836
837 emit urlChanged(homeUrl);
838 }
839
840 void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
841 {
842 Q_ASSERT(viewContainer != 0);
843 Q_ASSERT((viewContainer == m_viewTab[m_tabIndex].primaryView) ||
844 (viewContainer == m_viewTab[m_tabIndex].secondaryView));
845 if (m_activeViewContainer == viewContainer) {
846 return;
847 }
848
849 m_activeViewContainer->setActive(false);
850 m_activeViewContainer = viewContainer;
851
852 // Activating the view container might trigger a recursive setActiveViewContainer() call
853 // inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary
854 // disconnect the activated() signal in this case:
855 disconnect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
856 m_activeViewContainer->setActive(true);
857 connect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
858
859 m_actionHandler->setCurrentView(viewContainer->view());
860
861 updateHistory();
862 updateEditActions();
863 updateViewActions();
864 updateGoActions();
865
866 const KUrl& url = m_activeViewContainer->url();
867 setCaption(url.fileName());
868 if (m_viewTab.count() > 1) {
869 m_tabBar->setTabText(m_tabIndex, tabName(url));
870 }
871
872 emit urlChanged(url);
873 }
874
875 void DolphinMainWindow::setupActions()
876 {
877 // setup 'File' menu
878 m_newMenu = new DolphinNewMenu(this);
879 KMenu* menu = m_newMenu->menu();
880 menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
881 menu->setIcon(KIcon("document-new"));
882 connect(menu, SIGNAL(aboutToShow()),
883 this, SLOT(updateNewMenu()));
884
885 KAction* newWindow = actionCollection()->addAction("new_window");
886 newWindow->setIcon(KIcon("window-new"));
887 newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
888 newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
889 connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
890
891 KAction* newTab = actionCollection()->addAction("new_tab");
892 newTab->setIcon(KIcon("tab-new"));
893 newTab->setText(i18nc("@action:inmenu File", "New Tab"));
894 newTab->setShortcut(KShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_N, Qt::CTRL | Qt::Key_T));
895 connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
896
897 QAction* closeTab = new QAction(KIcon("tab-close"), i18nc("@action:inmenu File", "Close Tab"), this);
898 closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
899 connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
900 actionCollection()->addAction("close_tab", closeTab);
901
902 KStandardAction::quit(this, SLOT(quit()), actionCollection());
903
904 // setup 'Edit' menu
905 KStandardAction::undo(this,
906 SLOT(undo()),
907 actionCollection());
908
909 // need to remove shift+del from cut action, else the shortcut for deletejob
910 // doesn't work
911 KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
912 KShortcut cutShortcut = cut->shortcut();
913 cutShortcut.remove(Qt::SHIFT + Qt::Key_Delete, KShortcut::KeepEmpty);
914 cut->setShortcut(cutShortcut);
915 KStandardAction::copy(this, SLOT(copy()), actionCollection());
916 KStandardAction::paste(this, SLOT(paste()), actionCollection());
917
918 KAction* selectAll = actionCollection()->addAction("select_all");
919 selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
920 selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
921 connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
922
923 KAction* invertSelection = actionCollection()->addAction("invert_selection");
924 invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
925 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
926 connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
927
928 // setup 'View' menu
929 // (note that most of it is set up in DolphinViewActionHandler)
930
931 KAction* split = actionCollection()->addAction("split_view");
932 split->setShortcut(Qt::Key_F3);
933 updateSplitAction();
934 connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
935
936 KAction* reload = actionCollection()->addAction("reload");
937 reload->setText(i18nc("@action:inmenu View", "Reload"));
938 reload->setShortcut(Qt::Key_F5);
939 reload->setIcon(KIcon("view-refresh"));
940 connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
941
942 KAction* stop = actionCollection()->addAction("stop");
943 stop->setText(i18nc("@action:inmenu View", "Stop"));
944 stop->setIcon(KIcon("process-stop"));
945 connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
946
947 // TODO: the naming "Show full Location" is currently confusing...
948 KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
949 showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Show Full Location"));
950 showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
951 connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
952
953 KAction* editLocation = actionCollection()->addAction("edit_location");
954 editLocation->setText(i18nc("@action:inmenu Navigation Bar", "Edit Location"));
955 editLocation->setShortcut(Qt::Key_F6);
956 connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
957
958 // setup 'Go' menu
959 KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
960 KShortcut backShortcut = backAction->shortcut();
961 backShortcut.setAlternate(Qt::Key_Backspace);
962 backAction->setShortcut(backShortcut);
963
964 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
965 KStandardAction::up(this, SLOT(goUp()), actionCollection());
966 KStandardAction::home(this, SLOT(goHome()), actionCollection());
967
968 // setup 'Tools' menu
969 KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
970 showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
971 showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
972 connect(showFilterBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
973
974 KAction* compareFiles = actionCollection()->addAction("compare_files");
975 compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
976 compareFiles->setIcon(KIcon("kompare"));
977 compareFiles->setEnabled(false);
978 connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
979
980 // setup 'Settings' menu
981 m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
982 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
983 }
984
985 void DolphinMainWindow::setupDockWidgets()
986 {
987 // setup "Information"
988 QDockWidget* infoDock = new QDockWidget(i18nc("@title:window", "Information"));
989 infoDock->setObjectName("infoDock");
990 infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
991 SidebarPage* infoWidget = new InfoSidebarPage(infoDock);
992 infoDock->setWidget(infoWidget);
993
994 infoDock->toggleViewAction()->setText(i18nc("@title:window", "Information"));
995 infoDock->toggleViewAction()->setShortcut(Qt::Key_F11);
996 actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
997
998 addDockWidget(Qt::RightDockWidgetArea, infoDock);
999 connect(this, SIGNAL(urlChanged(KUrl)),
1000 infoWidget, SLOT(setUrl(KUrl)));
1001 connect(this, SIGNAL(selectionChanged(KFileItemList)),
1002 infoWidget, SLOT(setSelection(KFileItemList)));
1003 connect(this, SIGNAL(requestItemInfo(KFileItem)),
1004 infoWidget, SLOT(requestDelayedItemInfo(KFileItem)));
1005
1006 // setup "Tree View"
1007 QDockWidget* treeViewDock = new QDockWidget(i18nc("@title:window", "Folders"));
1008 treeViewDock->setObjectName("treeViewDock");
1009 treeViewDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1010 TreeViewSidebarPage* treeWidget = new TreeViewSidebarPage(treeViewDock);
1011 treeViewDock->setWidget(treeWidget);
1012
1013 treeViewDock->toggleViewAction()->setText(i18nc("@title:window", "Folders"));
1014 treeViewDock->toggleViewAction()->setShortcut(Qt::Key_F7);
1015 actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction());
1016
1017 addDockWidget(Qt::LeftDockWidgetArea, treeViewDock);
1018 connect(this, SIGNAL(urlChanged(KUrl)),
1019 treeWidget, SLOT(setUrl(KUrl)));
1020 connect(treeWidget, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)),
1021 this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
1022 connect(treeWidget, SIGNAL(changeSelection(KFileItemList)),
1023 this, SLOT(changeSelection(KFileItemList)));
1024 connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
1025 this, SLOT(dropUrls(KUrl::List, KUrl)));
1026
1027 // setup "Terminal"
1028 #ifndef Q_OS_WIN
1029 QDockWidget* terminalDock = new QDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1030 terminalDock->setObjectName("terminalDock");
1031 terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
1032 SidebarPage* terminalWidget = new TerminalSidebarPage(terminalDock);
1033 terminalDock->setWidget(terminalWidget);
1034
1035 connect(terminalWidget, SIGNAL(hideTerminalSidebarPage()), terminalDock, SLOT(hide()));
1036
1037 terminalDock->toggleViewAction()->setText(i18nc("@title:window Shell terminal", "Terminal"));
1038 terminalDock->toggleViewAction()->setShortcut(Qt::Key_F4);
1039 actionCollection()->addAction("show_terminal_panel", terminalDock->toggleViewAction());
1040
1041 addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
1042 connect(this, SIGNAL(urlChanged(KUrl)),
1043 terminalWidget, SLOT(setUrl(KUrl)));
1044 #endif
1045
1046 const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
1047 if (firstRun) {
1048 treeViewDock->hide();
1049 #ifndef Q_OS_WIN
1050 terminalDock->hide();
1051 #endif
1052 }
1053
1054 QDockWidget* placesDock = new QDockWidget(i18nc("@title:window", "Places"));
1055 placesDock->setObjectName("placesDock");
1056 placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1057
1058 DolphinFilePlacesView* placesView = new DolphinFilePlacesView(placesDock);
1059 placesDock->setWidget(placesView);
1060 placesView->setModel(DolphinSettings::instance().placesModel());
1061 placesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1062
1063 placesDock->toggleViewAction()->setText(i18nc("@title:window", "Places"));
1064 placesDock->toggleViewAction()->setShortcut(Qt::Key_F9);
1065 actionCollection()->addAction("show_places_panel", placesDock->toggleViewAction());
1066
1067 addDockWidget(Qt::LeftDockWidgetArea, placesDock);
1068 connect(placesView, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)),
1069 this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
1070 connect(this, SIGNAL(urlChanged(KUrl)),
1071 placesView, SLOT(setUrl(KUrl)));
1072 }
1073
1074 void DolphinMainWindow::updateEditActions()
1075 {
1076 const KFileItemList list = m_activeViewContainer->view()->selectedItems();
1077 if (list.isEmpty()) {
1078 stateChanged("has_no_selection");
1079 } else {
1080 stateChanged("has_selection");
1081
1082 KActionCollection* col = actionCollection();
1083 QAction* renameAction = col->action("rename");
1084 QAction* moveToTrashAction = col->action("move_to_trash");
1085 QAction* deleteAction = col->action("delete");
1086 QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
1087 QAction* deleteWithTrashShortcut = col->action("delete_shortcut"); // see DolphinViewActionHandler
1088
1089 KonqFileItemCapabilities capabilities(list);
1090 const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
1091
1092 renameAction->setEnabled(capabilities.supportsMoving());
1093 moveToTrashAction->setEnabled(enableMoveToTrash);
1094 deleteAction->setEnabled(capabilities.supportsDeleting());
1095 deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
1096 cutAction->setEnabled(capabilities.supportsMoving());
1097 }
1098 updatePasteAction();
1099 }
1100
1101 void DolphinMainWindow::updateViewActions()
1102 {
1103 m_actionHandler->updateViewActions();
1104
1105 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
1106 showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
1107
1108 updateSplitAction();
1109
1110 QAction* editableLocactionAction = actionCollection()->action("editable_location");
1111 const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
1112 editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
1113 }
1114
1115 void DolphinMainWindow::updateGoActions()
1116 {
1117 QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
1118 const KUrl& currentUrl = m_activeViewContainer->url();
1119 goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
1120 }
1121
1122 void DolphinMainWindow::clearStatusBar()
1123 {
1124 m_activeViewContainer->statusBar()->clear();
1125 }
1126
1127 void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
1128 {
1129 connect(container, SIGNAL(showFilterBarChanged(bool)),
1130 this, SLOT(updateFilterBarAction(bool)));
1131
1132 DolphinView* view = container->view();
1133 connect(view, SIGNAL(selectionChanged(KFileItemList)),
1134 this, SLOT(slotSelectionChanged(KFileItemList)));
1135 connect(view, SIGNAL(requestItemInfo(KFileItem)),
1136 this, SLOT(slotRequestItemInfo(KFileItem)));
1137 connect(view, SIGNAL(activated()),
1138 this, SLOT(toggleActiveView()));
1139 connect(view, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
1140 this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
1141 connect(view, SIGNAL(tabRequested(const KUrl&)),
1142 this, SLOT(openNewTab(const KUrl&)));
1143
1144 const KUrlNavigator* navigator = container->urlNavigator();
1145 connect(navigator, SIGNAL(urlChanged(const KUrl&)),
1146 this, SLOT(changeUrl(const KUrl&)));
1147 connect(navigator, SIGNAL(historyChanged()),
1148 this, SLOT(updateHistory()));
1149 connect(navigator, SIGNAL(editableStateChanged(bool)),
1150 this, SLOT(slotEditableStateChanged(bool)));
1151 }
1152
1153 void DolphinMainWindow::updateSplitAction()
1154 {
1155 QAction* splitAction = actionCollection()->action("split_view");
1156 if (m_viewTab[m_tabIndex].secondaryView != 0) {
1157 if (m_activeViewContainer == m_viewTab[m_tabIndex].secondaryView) {
1158 splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
1159 splitAction->setIcon(KIcon("view-right-close"));
1160 } else {
1161 splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
1162 splitAction->setIcon(KIcon("view-left-close"));
1163 }
1164 } else {
1165 splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
1166 splitAction->setIcon(KIcon("view-right-new"));
1167 }
1168 }
1169
1170 QString DolphinMainWindow::tabName(const KUrl& url) const
1171 {
1172 QString name;
1173 if (url.equals(KUrl("file:///"))) {
1174 name = "/";
1175 } else {
1176 name = url.fileName();
1177 if (name.isEmpty()) {
1178 name = url.protocol();
1179 }
1180 }
1181 return name;
1182 }
1183
1184 bool DolphinMainWindow::isKompareInstalled() const
1185 {
1186 static bool initialized = false;
1187 static bool installed = false;
1188 if (!initialized) {
1189 // TODO: maybe replace this approach later by using a menu
1190 // plugin like kdiff3plugin.cpp
1191 installed = !KGlobal::dirs()->findExe("kompare").isEmpty();
1192 initialized = true;
1193 }
1194 return installed;
1195 }
1196
1197 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
1198 KIO::FileUndoManager::UiInterface()
1199 {
1200 }
1201
1202 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1203 {
1204 }
1205
1206 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
1207 {
1208 DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
1209 if (mainWin) {
1210 DolphinStatusBar* statusBar = mainWin->activeViewContainer()->statusBar();
1211 statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
1212 } else {
1213 KIO::FileUndoManager::UiInterface::jobError(job);
1214 }
1215 }
1216
1217 #include "dolphinmainwindow.moc"