]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
setGroup -> KConfigGroup
[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
24 #include <assert.h>
25
26 #include "dolphinapplication.h"
27 #include "dolphinnewmenu.h"
28 #include "dolphinsettings.h"
29 #include "dolphinsettingsdialog.h"
30 #include "dolphinstatusbar.h"
31 #include "dolphinapplication.h"
32 #include "urlnavigator.h"
33 #include "dolphinsettings.h"
34 #include "bookmarkssidebarpage.h"
35 #include "infosidebarpage.h"
36 #include "generalsettings.h"
37 #include "viewpropertiesdialog.h"
38 #include "viewproperties.h"
39 #include "mainwindowadaptor.h"
40
41 #include <kaction.h>
42 #include <kactioncollection.h>
43 #include <kbookmarkmanager.h>
44 #include <kconfig.h>
45 #include <kdesktopfile.h>
46 #include <kdeversion.h>
47 #include <kfiledialog.h>
48 #include <kglobal.h>
49 #include <kicon.h>
50 #include <kiconloader.h>
51 #include <kio/netaccess.h>
52 #include <kio/deletejob.h>
53 #include <kio/renamedialog.h>
54 #include <kinputdialog.h>
55 #include <klocale.h>
56 #include <kmenu.h>
57 #include <kmessagebox.h>
58 #include <konqmimedata.h>
59 #include <kpropertiesdialog.h>
60 #include <kprotocolinfo.h>
61 #include <ktoggleaction.h>
62 #include <krun.h>
63 #include <kshell.h>
64 #include <kstandarddirs.h>
65 #include <kstatusbar.h>
66 #include <kstandardaction.h>
67 #include <kurl.h>
68
69 #include <QCloseEvent>
70 #include <QClipboard>
71 #include <QSplitter>
72 #include <QDockWidget>
73
74 DolphinMainWindow::DolphinMainWindow(int id) :
75 KMainWindow(0),
76 m_newMenu(0),
77 m_splitter(0),
78 m_activeView(0),
79 m_id(id)
80 {
81 setObjectName("Dolphin");
82 m_view[PrimaryIdx] = 0;
83 m_view[SecondaryIdx] = 0;
84
85 new MainWindowAdaptor(this);
86 QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);
87
88 KonqUndoManager::incRef();
89
90 KonqUndoManager* undoManager = KonqUndoManager::self();
91 undoManager->setUiInterface(new UndoUiInterface(this));
92
93 connect(undoManager, SIGNAL(undoAvailable(bool)),
94 this, SLOT(slotUndoAvailable(bool)));
95 connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
96 this, SLOT(slotUndoTextChanged(const QString&)));
97 }
98
99 DolphinMainWindow::~DolphinMainWindow()
100 {
101 KonqUndoManager::decRef();
102 DolphinApplication::app()->removeMainWindow(this);
103 }
104
105 void DolphinMainWindow::setActiveView(DolphinView* view)
106 {
107 assert((view == m_view[PrimaryIdx]) || (view == m_view[SecondaryIdx]));
108 if (m_activeView == view) {
109 return;
110 }
111
112 m_activeView = view;
113
114 updateHistory();
115 updateEditActions();
116 updateViewActions();
117 updateGoActions();
118
119 setCaption(m_activeView->url().fileName());
120
121 emit activeViewChanged();
122 }
123
124 void DolphinMainWindow::dropUrls(const KUrl::List& urls,
125 const KUrl& destination)
126 {
127 Qt::DropAction action = Qt::CopyAction;
128
129 Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
130 const bool shiftPressed = modifier & Qt::ShiftModifier;
131 const bool controlPressed = modifier & Qt::ControlModifier;
132 if (shiftPressed && controlPressed) {
133 // shortcut for 'Link Here' is used
134 action = Qt::LinkAction;
135 }
136 else if (shiftPressed) {
137 // shortcut for 'Move Here' is used
138 action = Qt::MoveAction;
139 }
140 else if (controlPressed) {
141 // shortcut for 'Copy Here' is used
142 action = Qt::CopyAction;
143 }
144 else {
145 // open a context menu which offers the following actions:
146 // - Move Here
147 // - Copy Here
148 // - Link Here
149 // - Cancel
150
151 KMenu popup(this);
152
153 QString seq = QKeySequence(Qt::ShiftModifier).toString();
154 seq.chop(1); // chop superfluous '+'
155 QAction* moveAction = popup.addAction(KIcon("goto"),
156 i18n("&Move Here") + "\t" + seq);
157
158 seq = QKeySequence(Qt::ControlModifier).toString();
159 seq.chop(1);
160 QAction* copyAction = popup.addAction(KIcon("editcopy"),
161 i18n("&Copy Here") + "\t" + seq);
162
163 seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString();
164 seq.chop(1);
165 QAction* linkAction = popup.addAction(KIcon("www"),
166 i18n("&Link Here") + "\t" + seq);
167
168 popup.addSeparator();
169 popup.addAction(KIcon("stop"), i18n("Cancel"));
170
171 QAction* activatedAction = popup.exec(QCursor::pos());
172 if (activatedAction == moveAction) {
173 action = Qt::MoveAction;
174 }
175 else if (activatedAction == copyAction) {
176 action = Qt::CopyAction;
177 }
178 else if (activatedAction == linkAction) {
179 action = Qt::LinkAction;
180 }
181 else {
182 return;
183 }
184 }
185
186 switch (action) {
187 case Qt::MoveAction:
188 moveUrls(urls, destination);
189 break;
190
191 case Qt::CopyAction:
192 copyUrls(urls, destination);
193 break;
194
195 case Qt::LinkAction:
196 linkUrls(urls, destination);
197 break;
198
199 default:
200 break;
201 }
202 }
203
204 void DolphinMainWindow::refreshViews()
205 {
206 const bool split = DolphinSettings::instance().generalSettings()->splitView();
207 const bool isPrimaryViewActive = (m_activeView == m_view[PrimaryIdx]);
208 KUrl url;
209 for (int i = PrimaryIdx; i <= SecondaryIdx; ++i) {
210 if (m_view[i] != 0) {
211 url = m_view[i]->url();
212
213 // delete view instance...
214 m_view[i]->close();
215 m_view[i]->deleteLater();
216 m_view[i] = 0;
217 }
218
219 if (split || (i == PrimaryIdx)) {
220 // ... and recreate it
221 ViewProperties props(url);
222 m_view[i] = new DolphinView(this,
223 m_splitter,
224 url,
225 props.viewMode(),
226 props.showHiddenFiles());
227 connectViewSignals(i);
228 m_view[i]->show();
229 }
230 }
231
232 m_activeView = isPrimaryViewActive ? m_view[PrimaryIdx] : m_view[SecondaryIdx];
233 assert(m_activeView != 0);
234
235 updateViewActions();
236 emit activeViewChanged();
237 }
238
239 void DolphinMainWindow::changeUrl(const QString& url)
240 {
241 if (activeView() != 0) {
242 activeView()->setUrl(KUrl(url));
243 }
244 }
245
246 void DolphinMainWindow::slotViewModeChanged()
247 {
248 updateViewActions();
249 }
250
251 void DolphinMainWindow::slotShowHiddenFilesChanged()
252 {
253 KToggleAction* showHiddenFilesAction =
254 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
255 showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
256 }
257
258 void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
259 {
260 QAction* action = 0;
261 switch (sorting) {
262 case DolphinView::SortByName:
263 action = actionCollection()->action("by_name");
264 break;
265 case DolphinView::SortBySize:
266 action = actionCollection()->action("by_size");
267 break;
268 case DolphinView::SortByDate:
269 action = actionCollection()->action("by_date");
270 break;
271 case DolphinView::SortByPermissions:
272 action = actionCollection()->action("by_permissions");
273 break;
274 case DolphinView::SortByOwner:
275 action = actionCollection()->action("by_owner");
276 break;
277 case DolphinView::SortByGroup:
278 action = actionCollection()->action("by_group");
279 break;
280 default:
281 break;
282 }
283
284 if (action != 0) {
285 KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
286 toggleAction->setChecked(true);
287 }
288 }
289
290 void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
291 {
292 KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
293 const bool sortDescending = (order == Qt::Descending);
294 descending->setChecked(sortDescending);
295 }
296
297 void DolphinMainWindow::slotSelectionChanged()
298 {
299 updateEditActions();
300
301 assert(m_view[PrimaryIdx] != 0);
302 int selectedUrlsCount = m_view[PrimaryIdx]->selectedUrls().count();
303 if (m_view[SecondaryIdx] != 0) {
304 selectedUrlsCount += m_view[SecondaryIdx]->selectedUrls().count();
305 }
306
307 QAction* compareFilesAction = actionCollection()->action("compare_files");
308 compareFilesAction->setEnabled(selectedUrlsCount == 2);
309
310 m_activeView->updateStatusBar();
311
312 emit selectionChanged();
313 }
314
315 void DolphinMainWindow::slotHistoryChanged()
316 {
317 updateHistory();
318 }
319
320 void DolphinMainWindow::slotUrlChanged(const KUrl& url)
321 {
322 updateEditActions();
323 updateGoActions();
324 setCaption(url.fileName());
325 }
326
327 void DolphinMainWindow::updateFilterBarAction(bool show)
328 {
329 KToggleAction* showFilterBarAction =
330 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
331 showFilterBarAction->setChecked(show);
332 }
333
334 void DolphinMainWindow::openNewMainWindow()
335 {
336 DolphinApplication::app()->createMainWindow()->show();
337 }
338
339 void DolphinMainWindow::closeEvent(QCloseEvent* event)
340 {
341 DolphinSettings& settings = DolphinSettings::instance();
342 GeneralSettings* generalSettings = settings.generalSettings();
343 generalSettings->setFirstRun(false);
344
345 settings.save();
346
347 // TODO: I assume there will be a generic way in KDE 4 to store the docks
348 // of the main window. In the meantime they are stored manually:
349 QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName());
350 filename.append("/panels_layout");
351 QFile file(filename);
352 if (file.open(QIODevice::WriteOnly)) {
353 QByteArray data = saveState();
354 file.write(data);
355 file.close();
356 }
357
358 KMainWindow::closeEvent(event);
359 }
360
361 void DolphinMainWindow::saveProperties(KConfig* config)
362 {
363 KConfigGroup primaryView = config->group("Primary view");
364 primaryView.writeEntry("Url", m_view[PrimaryIdx]->url().url());
365 primaryView.writeEntry("Editable Url", m_view[PrimaryIdx]->isUrlEditable());
366 if (m_view[SecondaryIdx] != 0) {
367 KConfigGroup secondaryView = config->group("Secondary view");
368 secondaryView.writeEntry("Url", m_view[SecondaryIdx]->url().url());
369 secondaryView.writeEntry("Editable Url", m_view[SecondaryIdx]->isUrlEditable());
370 }
371 }
372
373 void DolphinMainWindow::readProperties(KConfig* config)
374 {
375 const KConfigGroup primaryView = config->group("Primary view");
376 m_view[PrimaryIdx]->setUrl(primaryView.readEntry("Url"));
377 m_view[PrimaryIdx]->setUrlEditable(primaryView.readEntry("Editable Url", false));
378 if (config->hasGroup("Secondary view")) {
379 const KConfigGroup secondaryView = config->group("Secondary view");
380 if (m_view[SecondaryIdx] == 0) {
381 toggleSplitView();
382 }
383 m_view[SecondaryIdx]->setUrl(secondaryView.readEntry("Url"));
384 m_view[SecondaryIdx]->setUrlEditable(secondaryView.readEntry("Editable Url", false));
385 }
386 else if (m_view[SecondaryIdx] != 0) {
387 toggleSplitView();
388 }
389 }
390
391 void DolphinMainWindow::updateNewMenu()
392 {
393 m_newMenu->slotCheckUpToDate();
394 m_newMenu->setPopupFiles(activeView()->url());
395 }
396
397 void DolphinMainWindow::rename()
398 {
399 clearStatusBar();
400 m_activeView->renameSelectedItems();
401 }
402
403 void DolphinMainWindow::moveToTrash()
404 {
405 clearStatusBar();
406 const KUrl::List selectedUrls = m_activeView->selectedUrls();
407 KonqOperations::del(this, KonqOperations::TRASH, selectedUrls);
408 m_undoOperations.append(KonqOperations::TRASH);
409 }
410
411 void DolphinMainWindow::deleteItems()
412 {
413 clearStatusBar();
414
415 KUrl::List list = m_activeView->selectedUrls();
416 const uint itemCount = list.count();
417 assert(itemCount >= 1);
418
419 QString text;
420 if (itemCount > 1) {
421 text = i18n("Do you really want to delete the %1 selected items?",itemCount);
422 }
423 else {
424 const KUrl& url = list.first();
425 text = i18n("Do you really want to delete '%1'?",url.fileName());
426 }
427
428 const bool del = KMessageBox::warningContinueCancel(this,
429 text,
430 QString::null,
431 KGuiItem(i18n("Delete"), KIcon("editdelete"))
432 ) == KMessageBox::Continue;
433 if (del) {
434 KIO::Job* job = KIO::del(list);
435 connect(job, SIGNAL(result(KJob*)),
436 this, SLOT(slotHandleJobError(KJob*)));
437 connect(job, SIGNAL(result(KJob*)),
438 this, SLOT(slotDeleteFileFinished(KJob*)));
439 }
440 }
441
442 void DolphinMainWindow::properties()
443 {
444 const KFileItemList list = m_activeView->selectedItems();
445 new KPropertiesDialog(list, this);
446 }
447
448 void DolphinMainWindow::quit()
449 {
450 close();
451 }
452
453 void DolphinMainWindow::slotHandleJobError(KJob* job)
454 {
455 if (job->error() != 0) {
456 DolphinStatusBar* statusBar = m_activeView->statusBar();
457 statusBar->setMessage(job->errorString(),
458 DolphinStatusBar::Error);
459 }
460 }
461
462 void DolphinMainWindow::slotDeleteFileFinished(KJob* job)
463 {
464 if (job->error() == 0) {
465 DolphinStatusBar* statusBar = m_activeView->statusBar();
466 statusBar->setMessage(i18n("Delete operation completed."),
467 DolphinStatusBar::OperationCompleted);
468 }
469 }
470
471 void DolphinMainWindow::slotUndoAvailable(bool available)
472 {
473 QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
474 if (undoAction != 0) {
475 undoAction->setEnabled(available);
476 }
477
478 if (available && (m_undoOperations.count() > 0)) {
479 const KonqOperations::Operation op = m_undoOperations.takeFirst();
480 DolphinStatusBar* statusBar = m_activeView->statusBar();
481 switch (op) {
482 case KonqOperations::COPY:
483 statusBar->setMessage(i18n("Copy operation completed."),
484 DolphinStatusBar::OperationCompleted);
485 break;
486 case KonqOperations::MOVE:
487 statusBar->setMessage(i18n("Move operation completed."),
488 DolphinStatusBar::OperationCompleted);
489 break;
490 case KonqOperations::LINK:
491 statusBar->setMessage(i18n("Link operation completed."),
492 DolphinStatusBar::OperationCompleted);
493 break;
494 case KonqOperations::TRASH:
495 statusBar->setMessage(i18n("Move to trash operation completed."),
496 DolphinStatusBar::OperationCompleted);
497 break;
498 default:
499 break;
500 }
501
502 }
503 }
504
505 void DolphinMainWindow::slotUndoTextChanged(const QString& text)
506 {
507 QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
508 if (undoAction != 0) {
509 undoAction->setText(text);
510 }
511 }
512
513 void DolphinMainWindow::undo()
514 {
515 clearStatusBar();
516 KonqUndoManager::self()->undo();
517 }
518
519 void DolphinMainWindow::cut()
520 {
521 QMimeData* mimeData = new QMimeData();
522 const KUrl::List kdeUrls = m_activeView->selectedUrls();
523 const KUrl::List mostLocalUrls;
524 KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true);
525 QApplication::clipboard()->setMimeData(mimeData);
526 }
527
528 void DolphinMainWindow::copy()
529 {
530 QMimeData* mimeData = new QMimeData();
531 const KUrl::List kdeUrls = m_activeView->selectedUrls();
532 const KUrl::List mostLocalUrls;
533 KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false);
534
535 QApplication::clipboard()->setMimeData(mimeData);
536 }
537
538 void DolphinMainWindow::paste()
539 {
540 QClipboard* clipboard = QApplication::clipboard();
541 const QMimeData* mimeData = clipboard->mimeData();
542
543 clearStatusBar();
544
545 const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
546
547 // per default the pasting is done into the current Url of the view
548 KUrl destUrl(m_activeView->url());
549
550 // check whether the pasting should be done into a selected directory
551 KUrl::List selectedUrls = m_activeView->selectedUrls();
552 if (selectedUrls.count() == 1) {
553 const KFileItem fileItem(S_IFDIR,
554 KFileItem::Unknown,
555 selectedUrls.first(),
556 true);
557 if (fileItem.isDir()) {
558 // only one item is selected which is a directory, hence paste
559 // into this directory
560 destUrl = selectedUrls.first();
561 }
562 }
563
564 if (KonqMimeData::decodeIsCutSelection(mimeData)) {
565 moveUrls(sourceUrls, destUrl);
566 clipboard->clear();
567 }
568 else {
569 copyUrls(sourceUrls, destUrl);
570 }
571 }
572
573 void DolphinMainWindow::updatePasteAction()
574 {
575 QAction* pasteAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste));
576 if (pasteAction == 0) {
577 return;
578 }
579
580 QString text(i18n("Paste"));
581 QClipboard* clipboard = QApplication::clipboard();
582 const QMimeData* mimeData = clipboard->mimeData();
583
584 KUrl::List urls = KUrl::List::fromMimeData(mimeData);
585 if (!urls.isEmpty()) {
586 pasteAction->setEnabled(true);
587
588 const int count = urls.count();
589 if (count == 1) {
590 pasteAction->setText(i18n("Paste 1 File"));
591 }
592 else {
593 pasteAction->setText(i18n("Paste %1 Files").arg(count));
594 }
595 }
596 else {
597 pasteAction->setEnabled(false);
598 pasteAction->setText(i18n("Paste"));
599 }
600
601 if (pasteAction->isEnabled()) {
602 KUrl::List urls = m_activeView->selectedUrls();
603 const uint count = urls.count();
604 if (count > 1) {
605 // pasting should not be allowed when more than one file
606 // is selected
607 pasteAction->setEnabled(false);
608 }
609 else if (count == 1) {
610 // Only one file is selected. Pasting is only allowed if this
611 // file is a directory.
612 // TODO: this doesn't work with remote protocols; instead we need a
613 // m_activeView->selectedFileItems() to get the real KFileItems
614 const KFileItem fileItem(S_IFDIR,
615 KFileItem::Unknown,
616 urls.first(),
617 true);
618 pasteAction->setEnabled(fileItem.isDir());
619 }
620 }
621 }
622
623 void DolphinMainWindow::selectAll()
624 {
625 clearStatusBar();
626 m_activeView->selectAll();
627 }
628
629 void DolphinMainWindow::invertSelection()
630 {
631 clearStatusBar();
632 m_activeView->invertSelection();
633 }
634 void DolphinMainWindow::setIconsView()
635 {
636 m_activeView->setMode(DolphinView::IconsView);
637 }
638
639 void DolphinMainWindow::setDetailsView()
640 {
641 m_activeView->setMode(DolphinView::DetailsView);
642 }
643
644 void DolphinMainWindow::sortByName()
645 {
646 m_activeView->setSorting(DolphinView::SortByName);
647 }
648
649 void DolphinMainWindow::sortBySize()
650 {
651 m_activeView->setSorting(DolphinView::SortBySize);
652 }
653
654 void DolphinMainWindow::sortByDate()
655 {
656 m_activeView->setSorting(DolphinView::SortByDate);
657 }
658
659 void DolphinMainWindow::sortByPermissions()
660 {
661 m_activeView->setSorting(DolphinView::SortByPermissions);
662 }
663
664 void DolphinMainWindow::sortByOwner()
665 {
666 m_activeView->setSorting(DolphinView::SortByOwner);
667 }
668
669 void DolphinMainWindow::sortByGroup()
670 {
671 m_activeView->setSorting(DolphinView::SortByGroup);
672 }
673
674 void DolphinMainWindow::toggleSortOrder()
675 {
676 const Qt::SortOrder order = (m_activeView->sortOrder() == Qt::Ascending) ?
677 Qt::Descending :
678 Qt::Ascending;
679 m_activeView->setSortOrder(order);
680 }
681
682 void DolphinMainWindow::toggleSplitView()
683 {
684 if (m_view[SecondaryIdx] == 0) {
685 const int newWidth = (m_view[PrimaryIdx]->width() - m_splitter->handleWidth()) / 2;
686 // create a secondary view
687 m_view[SecondaryIdx] = new DolphinView(this,
688 0,
689 m_view[PrimaryIdx]->url(),
690 m_view[PrimaryIdx]->mode(),
691 m_view[PrimaryIdx]->showHiddenFiles());
692 connectViewSignals(SecondaryIdx);
693 m_splitter->addWidget(m_view[SecondaryIdx]);
694 m_splitter->setSizes(QList<int>() << newWidth << newWidth);
695 m_view[SecondaryIdx]->show();
696 }
697 else {
698 // remove secondary view
699 if (m_activeView == m_view[PrimaryIdx]) {
700 m_view[SecondaryIdx]->close();
701 m_view[SecondaryIdx]->deleteLater();
702 m_view[SecondaryIdx] = 0;
703 setActiveView(m_view[PrimaryIdx]);
704 }
705 else {
706 // The secondary view is active, hence from the users point of view
707 // the content of the secondary view should be moved to the primary view.
708 // From an implementation point of view it is more efficient to close
709 // the primary view and exchange the internal pointers afterwards.
710 m_view[PrimaryIdx]->close();
711 delete m_view[PrimaryIdx];
712 m_view[PrimaryIdx] = m_view[SecondaryIdx];
713 m_view[SecondaryIdx] = 0;
714 setActiveView(m_view[PrimaryIdx]);
715 }
716 }
717 emit activeViewChanged();
718 }
719
720 void DolphinMainWindow::reloadView()
721 {
722 clearStatusBar();
723 m_activeView->reload();
724 }
725
726 void DolphinMainWindow::stopLoading()
727 {
728 }
729
730 void DolphinMainWindow::togglePreview()
731 {
732 clearStatusBar();
733
734 const KToggleAction* showPreviewAction =
735 static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
736 const bool show = showPreviewAction->isChecked();
737 m_activeView->setShowPreview(show);
738 }
739
740 void DolphinMainWindow::toggleShowHiddenFiles()
741 {
742 clearStatusBar();
743
744 const KToggleAction* showHiddenFilesAction =
745 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
746 const bool show = showHiddenFilesAction->isChecked();
747 m_activeView->setShowHiddenFiles(show);
748 }
749
750 void DolphinMainWindow::showFilterBar()
751 {
752 const KToggleAction* showFilterBarAction =
753 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
754 const bool show = showFilterBarAction->isChecked();
755 m_activeView->showFilterBar(show);
756 }
757
758 void DolphinMainWindow::zoomIn()
759 {
760 m_activeView->zoomIn();
761 updateViewActions();
762 }
763
764 void DolphinMainWindow::zoomOut()
765 {
766 m_activeView->zoomOut();
767 updateViewActions();
768 }
769
770 void DolphinMainWindow::toggleEditLocation()
771 {
772 clearStatusBar();
773
774 KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
775
776 bool editOrBrowse = action->isChecked();
777 m_activeView->setUrlEditable(editOrBrowse);
778 }
779
780 void DolphinMainWindow::editLocation()
781 {
782 m_activeView->setUrlEditable(true);
783 }
784
785 void DolphinMainWindow::adjustViewProperties()
786 {
787 clearStatusBar();
788 ViewPropertiesDialog dlg(m_activeView);
789 dlg.exec();
790 }
791
792 void DolphinMainWindow::goBack()
793 {
794 clearStatusBar();
795 m_activeView->goBack();
796 }
797
798 void DolphinMainWindow::goForward()
799 {
800 clearStatusBar();
801 m_activeView->goForward();
802 }
803
804 void DolphinMainWindow::goUp()
805 {
806 clearStatusBar();
807 m_activeView->goUp();
808 }
809
810 void DolphinMainWindow::goHome()
811 {
812 clearStatusBar();
813 m_activeView->goHome();
814 }
815
816 void DolphinMainWindow::openTerminal()
817 {
818 QString command("konsole --workdir \"");
819 command.append(m_activeView->url().path());
820 command.append('\"');
821
822 KRun::runCommand(command, "Konsole", "konsole");
823 }
824
825 void DolphinMainWindow::findFile()
826 {
827 KRun::run("kfind", m_activeView->url());
828 }
829
830 void DolphinMainWindow::compareFiles()
831 {
832 // The method is only invoked if exactly 2 files have
833 // been selected. The selected files may be:
834 // - both in the primary view
835 // - both in the secondary view
836 // - one in the primary view and the other in the secondary
837 // view
838 assert(m_view[PrimaryIdx] != 0);
839
840 KUrl urlA;
841 KUrl urlB;
842 KUrl::List urls = m_view[PrimaryIdx]->selectedUrls();
843
844 switch (urls.count()) {
845 case 0: {
846 assert(m_view[SecondaryIdx] != 0);
847 urls = m_view[SecondaryIdx]->selectedUrls();
848 assert(urls.count() == 2);
849 urlA = urls[0];
850 urlB = urls[1];
851 break;
852 }
853
854 case 1: {
855 urlA = urls[0];
856 assert(m_view[SecondaryIdx] != 0);
857 urls = m_view[SecondaryIdx]->selectedUrls();
858 assert(urls.count() == 1);
859 urlB = urls[0];
860 break;
861 }
862
863 case 2: {
864 urlA = urls[0];
865 urlB = urls[1];
866 break;
867 }
868
869 default: {
870 // may not happen: compareFiles may only get invoked if 2
871 // files are selected
872 assert(false);
873 }
874 }
875
876 QString command("kompare -c \"");
877 command.append(urlA.pathOrUrl());
878 command.append("\" \"");
879 command.append(urlB.pathOrUrl());
880 command.append('\"');
881 KRun::runCommand(command, "Kompare", "kompare");
882
883 }
884
885 void DolphinMainWindow::editSettings()
886 {
887 // TODO: make a static method for opening the settings dialog
888 DolphinSettingsDialog dlg(this);
889 dlg.exec();
890 }
891
892 void DolphinMainWindow::init()
893 {
894 // Check whether Dolphin runs the first time. If yes then
895 // a proper default window size is given at the end of DolphinMainWindow::init().
896 GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
897 const bool firstRun = generalSettings->firstRun();
898 if (firstRun) {
899 generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
900 }
901
902 setAcceptDrops(true);
903
904 m_splitter = new QSplitter(this);
905
906 DolphinSettings& settings = DolphinSettings::instance();
907
908 KBookmarkManager* manager = settings.bookmarkManager();
909 assert(manager != 0);
910 KBookmarkGroup root = manager->root();
911 if (root.first().isNull()) {
912 root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder_home");
913 root.addBookmark(manager, i18n("Storage Media"), KUrl("media:/"), "blockdevice");
914 root.addBookmark(manager, i18n("Network"), KUrl("remote:/"), "network_local");
915 root.addBookmark(manager, i18n("Root"), KUrl("/"), "folder_red");
916 root.addBookmark(manager, i18n("Trash"), KUrl("trash:/"), "trashcan_full");
917 }
918
919 setupActions();
920
921 const KUrl& homeUrl = root.first().url();
922 setCaption(homeUrl.fileName());
923 ViewProperties props(homeUrl);
924 m_view[PrimaryIdx] = new DolphinView(this,
925 m_splitter,
926 homeUrl,
927 props.viewMode(),
928 props.showHiddenFiles());
929 connectViewSignals(PrimaryIdx);
930 m_view[PrimaryIdx]->show();
931
932 m_activeView = m_view[PrimaryIdx];
933
934 setCentralWidget(m_splitter);
935 setupDockWidgets();
936
937 setupGUI(Keys|Save|Create|ToolBar);
938 createGUI();
939
940 stateChanged("new_file");
941 setAutoSaveSettings();
942
943 QClipboard* clipboard = QApplication::clipboard();
944 connect(clipboard, SIGNAL(dataChanged()),
945 this, SLOT(updatePasteAction()));
946 updatePasteAction();
947 updateGoActions();
948
949 loadSettings();
950
951 if (firstRun) {
952 // assure a proper default size if Dolphin runs the first time
953 resize(640, 480);
954 }
955 }
956
957 void DolphinMainWindow::loadSettings()
958 {
959 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
960
961 KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
962 if (settings->splitView()) {
963 splitAction->setChecked(true);
964 toggleSplitView();
965 }
966
967 updateViewActions();
968
969 // TODO: I assume there will be a generic way in KDE 4 to restore the docks
970 // of the main window. In the meantime they are restored manually (see also
971 // DolphinMainWindow::closeEvent() for more details):
972 QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName()); filename.append("/panels_layout");
973 QFile file(filename);
974 if (file.open(QIODevice::ReadOnly)) {
975 QByteArray data = file.readAll();
976 restoreState(data);
977 file.close();
978 }
979 }
980
981 void DolphinMainWindow::setupActions()
982 {
983 // setup 'File' menu
984 m_newMenu = new DolphinNewMenu(this);
985 KMenu* menu = m_newMenu->menu();
986 menu->setTitle(i18n("Create New..."));
987 menu->setIcon(SmallIcon("filenew"));
988 connect(menu, SIGNAL(aboutToShow()),
989 this, SLOT(updateNewMenu()));
990
991 QAction* action = actionCollection()->addAction("new_window");
992 action->setIcon(KIcon("window_new"));
993 action->setText(i18n("New &Window"));
994 connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
995
996 QAction* rename = actionCollection()->addAction("rename");
997 rename->setText(i18n("Rename"));
998 rename->setShortcut(Qt::Key_F2);
999 connect(rename, SIGNAL(triggered()), this, SLOT(rename()));
1000
1001 QAction* moveToTrash = actionCollection()->addAction("move_to_trash");
1002 moveToTrash->setText(i18n("Move to Trash"));
1003 moveToTrash->setIcon(KIcon("edittrash"));
1004 moveToTrash->setShortcut(QKeySequence::Delete);
1005 connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash()));
1006
1007 QAction* deleteAction = actionCollection()->addAction("delete");
1008 deleteAction->setText(i18n("Delete"));
1009 deleteAction->setShortcut(Qt::ALT | Qt::Key_Delete);
1010 deleteAction->setIcon(KIcon("editdelete"));
1011 connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems()));
1012
1013 QAction* properties = actionCollection()->addAction("properties");
1014 properties->setText(i18n("Properties"));
1015 properties->setShortcut(Qt::ALT | Qt::Key_Return);
1016 connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
1017
1018 KStandardAction::quit(this, SLOT(quit()), actionCollection());
1019
1020 // setup 'Edit' menu
1021 KStandardAction::undo(this,
1022 SLOT(undo()),
1023 actionCollection());
1024
1025 KStandardAction::cut(this, SLOT(cut()), actionCollection());
1026 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1027 KStandardAction::paste(this, SLOT(paste()), actionCollection());
1028
1029 QAction* selectAll = actionCollection()->addAction("select_all");
1030 selectAll->setText(i18n("Select All"));
1031 selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
1032 connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
1033
1034 QAction* invertSelection = actionCollection()->addAction("invert_selection");
1035 invertSelection->setText(i18n("Invert Selection"));
1036 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
1037 connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
1038
1039 // setup 'View' menu
1040 KStandardAction::zoomIn(this,
1041 SLOT(zoomIn()),
1042 actionCollection());
1043
1044 KStandardAction::zoomOut(this,
1045 SLOT(zoomOut()),
1046 actionCollection());
1047
1048 KToggleAction* iconsView = actionCollection()->add<KToggleAction>("icons");
1049 iconsView->setText(i18n("Icons"));
1050 iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
1051 iconsView->setIcon(KIcon("view_icon"));
1052 connect(iconsView, SIGNAL(triggered()), this, SLOT(setIconsView()));
1053
1054 KToggleAction* detailsView = actionCollection()->add<KToggleAction>("details");
1055 detailsView->setText(i18n("Details"));
1056 detailsView->setShortcut(Qt::CTRL | Qt::Key_2);
1057 detailsView->setIcon(KIcon("view_text"));
1058 connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));
1059
1060 QActionGroup* viewModeGroup = new QActionGroup(this);
1061 viewModeGroup->addAction(iconsView);
1062 viewModeGroup->addAction(detailsView);
1063
1064 KToggleAction* sortByName = actionCollection()->add<KToggleAction>("by_name");
1065 sortByName->setText(i18n("By Name"));
1066 connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
1067
1068 KToggleAction* sortBySize = actionCollection()->add<KToggleAction>("by_size");
1069 sortBySize->setText(i18n("By Size"));
1070 connect(sortBySize, SIGNAL(triggered()), this, SLOT(sortBySize()));
1071
1072 KToggleAction* sortByDate = actionCollection()->add<KToggleAction>("by_date");
1073 sortByDate->setText(i18n("By Date"));
1074 connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate()));
1075
1076 KToggleAction* sortByPermissions = actionCollection()->add<KToggleAction>("by_permissions");
1077 sortByPermissions->setText(i18n("By Permissions"));
1078 connect(sortByPermissions, SIGNAL(triggered()), this, SLOT(sortByPermissions()));
1079
1080 KToggleAction* sortByOwner = actionCollection()->add<KToggleAction>("by_owner");
1081 sortByOwner->setText(i18n("By Owner"));
1082 connect(sortByOwner, SIGNAL(triggered()), this, SLOT(sortByOwner()));
1083
1084 KToggleAction* sortByGroup = actionCollection()->add<KToggleAction>("by_group");
1085 sortByGroup->setText(i18n("By Group"));
1086 connect(sortByGroup, SIGNAL(triggered()), this, SLOT(sortByGroup()));
1087
1088 QActionGroup* sortGroup = new QActionGroup(this);
1089 sortGroup->addAction(sortByName);
1090 sortGroup->addAction(sortBySize);
1091 sortGroup->addAction(sortByDate);
1092 sortGroup->addAction(sortByPermissions);
1093 sortGroup->addAction(sortByOwner);
1094 sortGroup->addAction(sortByGroup);
1095
1096 KToggleAction* sortDescending = actionCollection()->add<KToggleAction>("descending");
1097 sortDescending->setText(i18n("Descending"));
1098 connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
1099
1100 KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview");
1101 showPreview->setText(i18n("Show Preview"));
1102 connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
1103
1104 KToggleAction* showHiddenFiles = actionCollection()->add<KToggleAction>("show_hidden_files");
1105 showHiddenFiles->setText(i18n("Show Hidden Files"));
1106 showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);
1107 connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
1108
1109 KToggleAction* split = actionCollection()->add<KToggleAction>("split_view");
1110 split->setText(i18n("Split View"));
1111 split->setShortcut(Qt::Key_F10);
1112 split->setIcon(KIcon("view_left_right"));
1113 connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1114
1115 QAction* reload = actionCollection()->addAction("reload");
1116 reload->setText(i18n("Reload"));
1117 reload->setShortcut(Qt::Key_F5);
1118 reload->setIcon(KIcon("reload"));
1119 connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
1120
1121 QAction* stop = actionCollection()->addAction("stop");
1122 stop->setText(i18n("Stop"));
1123 stop->setIcon(KIcon("stop"));
1124 connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
1125
1126 // TODO: the URL navigator must emit a signal if the editable state has been
1127 // changed, so that the corresponding showFullLocation action is updated. Also
1128 // the naming "Show full Location" is currently confusing...
1129 KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
1130 showFullLocation->setText(i18n("Show Full Location"));
1131 showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
1132 connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1133
1134 QAction* editLocation = actionCollection()->addAction("edit_location");
1135 editLocation->setText(i18n("Edit Location"));
1136 editLocation->setShortcut(Qt::Key_F6);
1137 connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
1138
1139 QAction* adjustViewProps = actionCollection()->addAction("view_properties");
1140 adjustViewProps->setText(i18n("Adjust View Properties..."));
1141 connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
1142
1143 // setup 'Go' menu
1144 KStandardAction::back(this, SLOT(goBack()), actionCollection());
1145 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1146 KStandardAction::up(this, SLOT(goUp()), actionCollection());
1147 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1148
1149 // setup 'Tools' menu
1150 QAction* openTerminal = actionCollection()->addAction("open_terminal");
1151 openTerminal->setText(i18n("Open Terminal"));
1152 openTerminal->setShortcut(Qt::Key_F4);
1153 openTerminal->setIcon(KIcon("konsole"));
1154 connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
1155
1156 QAction* findFile = actionCollection()->addAction("find_file");
1157 findFile->setText(i18n("Find File..."));
1158 findFile->setShortcut(Qt::Key_F);
1159 findFile->setIcon(KIcon("filefind"));
1160 connect(findFile, SIGNAL(triggered()), this, SLOT(findFile()));
1161
1162 KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
1163 showFilterBar->setText(i18n("Show Filter Bar"));
1164 showFilterBar->setShortcut(Qt::Key_Slash);
1165 connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
1166
1167 QAction* compareFiles = actionCollection()->addAction("compare_files");
1168 compareFiles->setText(i18n("Compare Files"));
1169 compareFiles->setIcon(KIcon("kompare"));
1170 compareFiles->setEnabled(false);
1171 connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
1172
1173 // setup 'Settings' menu
1174 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1175 }
1176
1177 void DolphinMainWindow::setupDockWidgets()
1178 {
1179 QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks"));
1180 shortcutsDock->setObjectName("bookmarksDock");
1181 shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1182 shortcutsDock->setWidget(new BookmarksSidebarPage(this));
1183
1184 shortcutsDock->toggleViewAction()->setText(i18n("Show Bookmarks Panel"));
1185 actionCollection()->addAction("show_bookmarks_panel", shortcutsDock->toggleViewAction());
1186
1187 addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
1188
1189 QDockWidget* infoDock = new QDockWidget(i18n("Information"));
1190 infoDock->setObjectName("infoDock");
1191 infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1192 infoDock->setWidget(new InfoSidebarPage(this));
1193
1194 infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
1195 actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
1196
1197 addDockWidget(Qt::RightDockWidgetArea, infoDock);
1198 }
1199
1200 void DolphinMainWindow::updateHistory()
1201 {
1202 int index = 0;
1203 const QLinkedList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
1204
1205 QAction* backAction = actionCollection()->action("go_back");
1206 if (backAction != 0) {
1207 backAction->setEnabled(index < static_cast<int>(list.count()) - 1);
1208 }
1209
1210 QAction* forwardAction = actionCollection()->action("go_forward");
1211 if (forwardAction != 0) {
1212 forwardAction->setEnabled(index > 0);
1213 }
1214 }
1215
1216 void DolphinMainWindow::updateEditActions()
1217 {
1218 const KFileItemList list = m_activeView->selectedItems();
1219 if (list.isEmpty()) {
1220 stateChanged("has_no_selection");
1221 }
1222 else {
1223 stateChanged("has_selection");
1224
1225 QAction* renameAction = actionCollection()->action("rename");
1226 if (renameAction != 0) {
1227 renameAction->setEnabled(list.count() >= 1);
1228 }
1229
1230 bool enableMoveToTrash = true;
1231
1232 KFileItemList::const_iterator it = list.begin();
1233 const KFileItemList::const_iterator end = list.end();
1234 while (it != end) {
1235 KFileItem* item = *it;
1236 const KUrl& url = item->url();
1237 // only enable the 'Move to Trash' action for local files
1238 if (!url.isLocalFile()) {
1239 enableMoveToTrash = false;
1240 }
1241 ++it;
1242 }
1243
1244 QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
1245 moveToTrashAction->setEnabled(enableMoveToTrash);
1246 }
1247 updatePasteAction();
1248 }
1249
1250 void DolphinMainWindow::updateViewActions()
1251 {
1252 QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn));
1253 if (zoomInAction != 0) {
1254 zoomInAction->setEnabled(m_activeView->isZoomInPossible());
1255 }
1256
1257 QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut));
1258 if (zoomOutAction != 0) {
1259 zoomOutAction->setEnabled(m_activeView->isZoomOutPossible());
1260 }
1261
1262 QAction* action = 0;
1263 switch (m_activeView->mode()) {
1264 case DolphinView::IconsView:
1265 action = actionCollection()->action("icons");
1266 break;
1267 case DolphinView::DetailsView:
1268 action = actionCollection()->action("details");
1269 break;
1270 default:
1271 break;
1272 }
1273
1274 if (action != 0) {
1275 KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
1276 toggleAction->setChecked(true);
1277 }
1278
1279 slotSortingChanged(m_activeView->sorting());
1280 slotSortOrderChanged(m_activeView->sortOrder());
1281
1282 KToggleAction* showFilterBarAction =
1283 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
1284 showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
1285
1286 KToggleAction* showHiddenFilesAction =
1287 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
1288 showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
1289
1290 KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
1291 splitAction->setChecked(m_view[SecondaryIdx] != 0);
1292
1293 KToggleAction* editableLocactionAction =
1294 static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
1295 editableLocactionAction->setChecked(m_activeView->isUrlEditable());
1296 }
1297
1298 void DolphinMainWindow::updateGoActions()
1299 {
1300 QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Up));
1301 const KUrl& currentUrl = m_activeView->url();
1302 goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
1303 }
1304
1305 void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest)
1306 {
1307 KonqOperations::copy(this, KonqOperations::COPY, source, dest);
1308 m_undoOperations.append(KonqOperations::COPY);
1309 }
1310
1311 void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
1312 {
1313 KonqOperations::copy(this, KonqOperations::MOVE, source, dest);
1314 m_undoOperations.append(KonqOperations::MOVE);
1315 }
1316
1317 void DolphinMainWindow::linkUrls(const KUrl::List& source, const KUrl& dest)
1318 {
1319 KonqOperations::copy(this, KonqOperations::LINK, source, dest);
1320 m_undoOperations.append(KonqOperations::LINK);
1321 }
1322
1323 void DolphinMainWindow::clearStatusBar()
1324 {
1325 m_activeView->statusBar()->clear();
1326 }
1327
1328 void DolphinMainWindow::connectViewSignals(int viewIndex)
1329 {
1330 DolphinView* view = m_view[viewIndex];
1331 connect(view, SIGNAL(modeChanged()),
1332 this, SLOT(slotViewModeChanged()));
1333 connect(view, SIGNAL(showHiddenFilesChanged()),
1334 this, SLOT(slotShowHiddenFilesChanged()));
1335 connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
1336 this, SLOT(slotSortingChanged(DolphinView::Sorting)));
1337 connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
1338 this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
1339 connect(view, SIGNAL(selectionChanged()),
1340 this, SLOT(slotSelectionChanged()));
1341 connect(view, SIGNAL(showFilterBarChanged(bool)),
1342 this, SLOT(updateFilterBarAction(bool)));
1343
1344 const UrlNavigator* navigator = view->urlNavigator();
1345 connect(navigator, SIGNAL(urlChanged(const KUrl&)),
1346 this, SLOT(slotUrlChanged(const KUrl&)));
1347 connect(navigator, SIGNAL(historyChanged()),
1348 this, SLOT(slotHistoryChanged()));
1349
1350 }
1351
1352 DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
1353 KonqUndoManager::UiInterface(mainWin),
1354 m_mainWin(mainWin)
1355 {
1356 assert(m_mainWin != 0);
1357 }
1358
1359 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1360 {
1361 }
1362
1363 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
1364 {
1365 DolphinStatusBar* statusBar = m_mainWin->activeView()->statusBar();
1366 statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
1367 }
1368
1369 #include "dolphinmainwindow.moc"