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> *
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. *
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. *
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 ***************************************************************************/
22 #include "dolphinmainwindow.h"
23 #include "dolphinviewactionhandler.h"
25 #include <config-nepomuk.h>
27 #include "dolphinapplication.h"
28 #include "dolphinnewmenu.h"
29 #include "settings/dolphinsettings.h"
30 #include "settings/dolphinsettingsdialog.h"
31 #include "dolphinstatusbar.h"
32 #include "dolphinviewcontainer.h"
33 #include "panels/folders/folderspanel.h"
34 #include "panels/places/placespanel.h"
35 #include "panels/information/informationpanel.h"
36 #include "panels/information/metadatawidget.h"
37 #include "mainwindowadaptor.h"
38 #include "viewproperties.h"
41 #include "panels/terminal/terminalpanel.h"
44 #include "dolphin_generalsettings.h"
45 #include "dolphin_iconsmodesettings.h"
46 #include "draganddrophelper.h"
49 #include <kactioncollection.h>
51 #include <kdesktopfile.h>
52 #include <kdeversion.h>
53 #include <kfiledialog.h>
54 #include <kfileplacesmodel.h>
57 #include <kiconloader.h>
58 #include <kio/netaccess.h>
59 #include <kinputdialog.h>
61 #include <kprotocolmanager.h>
64 #include <kmessagebox.h>
65 #include <konq_fileitemcapabilities.h>
66 #include <konqmimedata.h>
67 #include <kprotocolinfo.h>
70 #include <kstandarddirs.h>
71 #include <kstatusbar.h>
72 #include <kstandardaction.h>
74 #include <ktoggleaction.h>
75 #include <kurlnavigator.h>
77 #include <kurlcombobox.h>
79 #include <QDBusMessage>
84 #include <QDockWidget>
86 DolphinMainWindow::DolphinMainWindow(int id
) :
91 m_activeViewContainer(0),
92 m_centralWidgetLayout(0),
99 setObjectName("Dolphin#");
101 m_viewTab
.append(ViewTab());
103 new MainWindowAdaptor(this);
104 QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id
), this);
106 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
107 undoManager
->setUiInterface(new UndoUiInterface());
109 connect(undoManager
, SIGNAL(undoAvailable(bool)),
110 this, SLOT(slotUndoAvailable(bool)));
111 connect(undoManager
, SIGNAL(undoTextChanged(const QString
&)),
112 this, SLOT(slotUndoTextChanged(const QString
&)));
113 connect(undoManager
, SIGNAL(jobRecordingStarted(CommandType
)),
114 this, SLOT(clearStatusBar()));
115 connect(undoManager
, SIGNAL(jobRecordingFinished(CommandType
)),
116 this, SLOT(showCommand(CommandType
)));
117 connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString
&)),
118 this, SLOT(showErrorMessage(const QString
&)));
119 connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString
&)),
120 this, SLOT(showErrorMessage(const QString
&)));
123 DolphinMainWindow::~DolphinMainWindow()
125 DolphinApplication::app()->removeMainWindow(this);
128 void DolphinMainWindow::toggleViews()
130 if (m_viewTab
[m_tabIndex
].primaryView
== 0) {
134 // move secondary view from the last position of the splitter
135 // to the first position
136 m_viewTab
[m_tabIndex
].splitter
->insertWidget(0, m_viewTab
[m_tabIndex
].secondaryView
);
138 DolphinViewContainer
* container
= m_viewTab
[m_tabIndex
].primaryView
;
139 m_viewTab
[m_tabIndex
].primaryView
= m_viewTab
[m_tabIndex
].secondaryView
;
140 m_viewTab
[m_tabIndex
].secondaryView
= container
;
143 void DolphinMainWindow::showCommand(CommandType command
)
145 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
147 case KIO::FileUndoManager::Copy
:
148 statusBar
->setMessage(i18nc("@info:status", "Copy operation completed."),
149 DolphinStatusBar::OperationCompleted
);
151 case KIO::FileUndoManager::Move
:
152 statusBar
->setMessage(i18nc("@info:status", "Move operation completed."),
153 DolphinStatusBar::OperationCompleted
);
155 case KIO::FileUndoManager::Link
:
156 statusBar
->setMessage(i18nc("@info:status", "Link operation completed."),
157 DolphinStatusBar::OperationCompleted
);
159 case KIO::FileUndoManager::Trash
:
160 statusBar
->setMessage(i18nc("@info:status", "Move to trash operation completed."),
161 DolphinStatusBar::OperationCompleted
);
163 case KIO::FileUndoManager::Rename
:
164 statusBar
->setMessage(i18nc("@info:status", "Renaming operation completed."),
165 DolphinStatusBar::OperationCompleted
);
168 case KIO::FileUndoManager::Mkdir
:
169 statusBar
->setMessage(i18nc("@info:status", "Created folder."),
170 DolphinStatusBar::OperationCompleted
);
178 void DolphinMainWindow::refreshViews()
180 Q_ASSERT(m_viewTab
[m_tabIndex
].primaryView
!= 0);
182 // remember the current active view, as because of
183 // the refreshing the active view might change to
184 // the secondary view
185 DolphinViewContainer
* activeViewContainer
= m_activeViewContainer
;
187 const int tabCount
= m_viewTab
.count();
188 for (int i
= 0; i
< tabCount
; ++i
) {
189 m_viewTab
[i
].primaryView
->refresh();
190 if (m_viewTab
[i
].secondaryView
!= 0) {
191 m_viewTab
[i
].secondaryView
->refresh();
195 setActiveViewContainer(activeViewContainer
);
198 void DolphinMainWindow::pasteIntoFolder()
200 m_activeViewContainer
->view()->pasteIntoFolder();
203 void DolphinMainWindow::changeUrl(const KUrl
& url
)
205 if (!KProtocolManager::supportsListing(url
)) {
206 // The URL navigator only checks for validity, not
207 // if the URL can be listed. An error message is
208 // shown due to DolphinViewContainer::restoreView().
212 DolphinViewContainer
* view
= activeViewContainer();
218 setCaption(url
.fileName());
219 if (m_viewTab
.count() > 1) {
220 m_tabBar
->setTabText(m_tabIndex
, tabName(url
));
222 emit
urlChanged(url
);
226 void DolphinMainWindow::changeSelection(const KFileItemList
& selection
)
228 activeViewContainer()->view()->changeSelection(selection
);
231 void DolphinMainWindow::slotEditableStateChanged(bool editable
)
233 KToggleAction
* editableLocationAction
=
234 static_cast<KToggleAction
*>(actionCollection()->action("editable_location"));
235 editableLocationAction
->setChecked(editable
);
238 void DolphinMainWindow::slotSelectionChanged(const KFileItemList
& selection
)
242 Q_ASSERT(m_viewTab
[m_tabIndex
].primaryView
!= 0);
243 int selectedUrlsCount
= m_viewTab
[m_tabIndex
].primaryView
->view()->selectedItemsCount();
244 if (m_viewTab
[m_tabIndex
].secondaryView
!= 0) {
245 selectedUrlsCount
+= m_viewTab
[m_tabIndex
].secondaryView
->view()->selectedItemsCount();
248 QAction
* compareFilesAction
= actionCollection()->action("compare_files");
249 if (selectedUrlsCount
== 2) {
250 compareFilesAction
->setEnabled(isKompareInstalled());
252 compareFilesAction
->setEnabled(false);
255 #if defined(QUICK_VIEW)
256 const bool activeViewHasSelection
= (activeViewContainer()->view()->selectedItemsCount() > 0);
257 actionCollection()->action("quick_view")->setEnabled(activeViewHasSelection
);
260 m_activeViewContainer
->updateStatusBar();
262 emit
selectionChanged(selection
);
265 void DolphinMainWindow::slotRequestItemInfo(const KFileItem
& item
)
267 emit
requestItemInfo(item
);
270 void DolphinMainWindow::updateHistory()
272 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
273 const int index
= urlNavigator
->historyIndex();
275 QAction
* backAction
= actionCollection()->action("go_back");
276 if (backAction
!= 0) {
277 backAction
->setEnabled(index
< urlNavigator
->historySize() - 1);
280 QAction
* forwardAction
= actionCollection()->action("go_forward");
281 if (forwardAction
!= 0) {
282 forwardAction
->setEnabled(index
> 0);
286 void DolphinMainWindow::updateFilterBarAction(bool show
)
288 QAction
* showFilterBarAction
= actionCollection()->action("show_filter_bar");
289 showFilterBarAction
->setChecked(show
);
292 void DolphinMainWindow::openNewMainWindow()
294 DolphinApplication::app()->createMainWindow()->show();
297 void DolphinMainWindow::openNewTab()
299 openNewTab(m_activeViewContainer
->url());
300 m_tabBar
->setCurrentIndex(m_viewTab
.count() - 1);
302 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
303 if (navigator
->isUrlEditable()) {
304 // if a new tab is opened and the URL is editable, assure that
305 // the user can edit the URL without manually setting the focus
306 navigator
->setFocus();
310 void DolphinMainWindow::openNewTab(const KUrl
& url
)
312 if (m_viewTab
.count() == 1) {
313 // Only one view is open currently and hence no tab is shown at
314 // all. Before creating a tab for 'url', provide a tab for the current URL.
315 m_tabBar
->addTab(KIcon("folder"), tabName(m_activeViewContainer
->url()));
316 m_tabBar
->blockSignals(false);
319 m_tabBar
->addTab(KIcon("folder"), tabName(url
));
322 viewTab
.splitter
= new QSplitter(this);
323 viewTab
.primaryView
= new DolphinViewContainer(this, viewTab
.splitter
, url
);
324 viewTab
.primaryView
->setActive(false);
325 connectViewSignals(viewTab
.primaryView
);
326 viewTab
.primaryView
->view()->reload();
328 m_viewTab
.append(viewTab
);
330 actionCollection()->action("close_tab")->setEnabled(true);
332 // provide a split view, if the startup settings are set this way
333 const GeneralSettings
* generalSettings
= DolphinSettings::instance().generalSettings();
334 if (generalSettings
->splitView()) {
335 const int tabIndex
= m_viewTab
.count() - 1;
336 createSecondaryView(tabIndex
);
337 m_viewTab
[tabIndex
].secondaryView
->setActive(true);
338 m_viewTab
[tabIndex
].isPrimaryViewActive
= false;
342 void DolphinMainWindow::activateNextTab()
344 if (m_viewTab
.count() == 1 || m_tabBar
->count() < 2) {
348 const int tabIndex
= (m_tabBar
->currentIndex() + 1) % m_tabBar
->count();
349 m_tabBar
->setCurrentIndex(tabIndex
);
352 void DolphinMainWindow::activatePrevTab()
354 if (m_viewTab
.count() == 1 || m_tabBar
->count() < 2) {
358 int tabIndex
= m_tabBar
->currentIndex() - 1;
359 if (tabIndex
== -1) {
360 tabIndex
= m_tabBar
->count() - 1;
362 m_tabBar
->setCurrentIndex(tabIndex
);
365 void DolphinMainWindow::openInNewTab()
367 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
368 if ((list
.count() == 1) && list
[0].isDir()) {
369 openNewTab(m_activeViewContainer
->view()->selectedUrls()[0]);
373 void DolphinMainWindow::openInNewWindow()
375 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
376 if ((list
.count() == 1) && list
[0].isDir()) {
377 DolphinMainWindow
* window
= DolphinApplication::app()->createMainWindow();
378 window
->changeUrl(m_activeViewContainer
->view()->selectedUrls()[0]);
383 void DolphinMainWindow::toggleActiveView()
385 if (m_viewTab
[m_tabIndex
].secondaryView
== 0) {
386 // only one view is available
390 Q_ASSERT(m_activeViewContainer
!= 0);
391 Q_ASSERT(m_viewTab
[m_tabIndex
].primaryView
!= 0);
393 DolphinViewContainer
* left
= m_viewTab
[m_tabIndex
].primaryView
;
394 DolphinViewContainer
* right
= m_viewTab
[m_tabIndex
].secondaryView
;
395 setActiveViewContainer(m_activeViewContainer
== right
? left
: right
);
398 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
400 DolphinSettings
& settings
= DolphinSettings::instance();
401 GeneralSettings
* generalSettings
= settings
.generalSettings();
402 generalSettings
->setFirstRun(false);
406 KXmlGuiWindow::closeEvent(event
);
409 void DolphinMainWindow::saveProperties(KConfigGroup
& group
)
411 // TODO: remember tabs
412 DolphinViewContainer
* cont
= m_viewTab
[m_tabIndex
].primaryView
;
413 group
.writeEntry("Primary Url", cont
->url().url());
414 group
.writeEntry("Primary Editable Url", cont
->isUrlEditable());
416 cont
= m_viewTab
[m_tabIndex
].secondaryView
;
418 group
.writeEntry("Secondary Url", cont
->url().url());
419 group
.writeEntry("Secondary Editable Url", cont
->isUrlEditable());
423 void DolphinMainWindow::readProperties(const KConfigGroup
& group
)
426 DolphinViewContainer
* cont
= m_viewTab
[m_tabIndex
].primaryView
;
428 cont
->setUrl(group
.readEntry("Primary Url"));
429 bool editable
= group
.readEntry("Primary Editable Url", false);
430 cont
->urlNavigator()->setUrlEditable(editable
);
432 cont
= m_viewTab
[m_tabIndex
].secondaryView
;
433 const QString secondaryUrl
= group
.readEntry("Secondary Url");
434 if (!secondaryUrl
.isEmpty()) {
436 // a secondary view should be shown, but no one is available
437 // currently -> create a new view
439 cont
= m_viewTab
[m_tabIndex
].secondaryView
;
443 cont
->setUrl(secondaryUrl
);
444 bool editable
= group
.readEntry("Secondary Editable Url", false);
445 cont
->urlNavigator()->setUrlEditable(editable
);
446 } else if (cont
!= 0) {
447 // no secondary view should be shown, but the default setting shows
448 // one already -> close the view
453 void DolphinMainWindow::updateNewMenu()
455 m_newMenu
->slotCheckUpToDate();
456 m_newMenu
->setPopupFiles(activeViewContainer()->url());
459 void DolphinMainWindow::quit()
464 void DolphinMainWindow::showErrorMessage(const QString
& message
)
466 if (!message
.isEmpty()) {
467 DolphinStatusBar
* statusBar
= m_activeViewContainer
->statusBar();
468 statusBar
->setMessage(message
, DolphinStatusBar::Error
);
472 void DolphinMainWindow::slotUndoAvailable(bool available
)
474 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
475 if (undoAction
!= 0) {
476 undoAction
->setEnabled(available
);
480 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
482 QAction
* undoAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Undo
));
483 if (undoAction
!= 0) {
484 undoAction
->setText(text
);
488 void DolphinMainWindow::undo()
491 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
492 KIO::FileUndoManager::self()->undo();
495 void DolphinMainWindow::cut()
497 m_activeViewContainer
->view()->cutSelectedItems();
500 void DolphinMainWindow::copy()
502 m_activeViewContainer
->view()->copySelectedItems();
505 void DolphinMainWindow::paste()
507 m_activeViewContainer
->view()->paste();
510 void DolphinMainWindow::updatePasteAction()
512 QAction
* pasteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Paste
));
513 QPair
<bool, QString
> pasteInfo
= m_activeViewContainer
->view()->pasteInfo();
514 pasteAction
->setEnabled(pasteInfo
.first
);
515 pasteAction
->setText(pasteInfo
.second
);
518 void DolphinMainWindow::selectAll()
522 // if the URL navigator is editable and focused, select the whole
523 // URL instead of all items of the view
525 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
526 QLineEdit
* lineEdit
= urlNavigator
->editor()->lineEdit();
527 const bool selectUrl
= urlNavigator
->isUrlEditable() &&
528 lineEdit
->hasFocus();
530 lineEdit
->selectAll();
532 m_activeViewContainer
->view()->selectAll();
536 void DolphinMainWindow::invertSelection()
539 m_activeViewContainer
->view()->invertSelection();
542 void DolphinMainWindow::toggleSplitView()
544 if (m_viewTab
[m_tabIndex
].secondaryView
== 0) {
545 createSecondaryView(m_tabIndex
);
546 setActiveViewContainer(m_viewTab
[m_tabIndex
].secondaryView
);
547 } else if (m_activeViewContainer
== m_viewTab
[m_tabIndex
].secondaryView
) {
548 // remove secondary view
549 m_viewTab
[m_tabIndex
].secondaryView
->close();
550 m_viewTab
[m_tabIndex
].secondaryView
->deleteLater();
551 m_viewTab
[m_tabIndex
].secondaryView
= 0;
553 setActiveViewContainer(m_viewTab
[m_tabIndex
].primaryView
);
555 // The primary view is active and should be closed. Hence from a users point of view
556 // the content of the secondary view should be moved to the primary view.
557 // From an implementation point of view it is more efficient to close
558 // the primary view and exchange the internal pointers afterwards.
560 m_viewTab
[m_tabIndex
].primaryView
->close();
561 m_viewTab
[m_tabIndex
].primaryView
->deleteLater();
562 m_viewTab
[m_tabIndex
].primaryView
= m_viewTab
[m_tabIndex
].secondaryView
;
563 m_viewTab
[m_tabIndex
].secondaryView
= 0;
565 setActiveViewContainer(m_viewTab
[m_tabIndex
].primaryView
);
571 void DolphinMainWindow::reloadView()
574 m_activeViewContainer
->view()->reload();
577 void DolphinMainWindow::stopLoading()
581 void DolphinMainWindow::toggleFilterBarVisibility(bool show
)
583 m_activeViewContainer
->showFilterBar(show
);
586 void DolphinMainWindow::toggleEditLocation()
590 QAction
* action
= actionCollection()->action("editable_location");
591 KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
592 urlNavigator
->setUrlEditable(action
->isChecked());
595 void DolphinMainWindow::replaceLocation()
597 KUrlNavigator
* navigator
= m_activeViewContainer
->urlNavigator();
598 navigator
->setUrlEditable(true);
599 navigator
->setFocus();
601 // select the whole text of the combo box editor
602 QLineEdit
* lineEdit
= navigator
->editor()->lineEdit();
603 const QString text
= lineEdit
->text();
604 lineEdit
->setSelection(0, text
.length());
607 void DolphinMainWindow::goBack()
610 m_activeViewContainer
->urlNavigator()->goBack();
613 void DolphinMainWindow::goForward()
616 m_activeViewContainer
->urlNavigator()->goForward();
619 void DolphinMainWindow::goUp()
622 m_activeViewContainer
->urlNavigator()->goUp();
625 void DolphinMainWindow::goHome()
628 m_activeViewContainer
->urlNavigator()->goHome();
631 void DolphinMainWindow::compareFiles()
633 // The method is only invoked if exactly 2 files have
634 // been selected. The selected files may be:
635 // - both in the primary view
636 // - both in the secondary view
637 // - one in the primary view and the other in the secondary
639 Q_ASSERT(m_viewTab
[m_tabIndex
].primaryView
!= 0);
643 KUrl::List urls
= m_viewTab
[m_tabIndex
].primaryView
->view()->selectedUrls();
645 switch (urls
.count()) {
647 Q_ASSERT(m_viewTab
[m_tabIndex
].secondaryView
!= 0);
648 urls
= m_viewTab
[m_tabIndex
].secondaryView
->view()->selectedUrls();
649 Q_ASSERT(urls
.count() == 2);
657 Q_ASSERT(m_viewTab
[m_tabIndex
].secondaryView
!= 0);
658 urls
= m_viewTab
[m_tabIndex
].secondaryView
->view()->selectedUrls();
659 Q_ASSERT(urls
.count() == 1);
671 // may not happen: compareFiles may only get invoked if 2
672 // files are selected
677 QString
command("kompare -c \"");
678 command
.append(urlA
.pathOrUrl());
679 command
.append("\" \"");
680 command
.append(urlB
.pathOrUrl());
681 command
.append('\"');
682 KRun::runCommand(command
, "Kompare", "kompare", this);
685 void DolphinMainWindow::quickView()
687 const KUrl::List urls
= activeViewContainer()->view()->selectedUrls();
688 Q_ASSERT(urls
.count() > 0);
690 QDBusMessage msg
= QDBusMessage::createMethodCall("org.kde.plasma", "/Previewer", "", "openFile");
691 foreach (const KUrl
& url
, urls
) {
692 msg
.setArguments(QList
<QVariant
>() << url
.prettyUrl());
693 QDBusConnection::sessionBus().send(msg
);
697 void DolphinMainWindow::toggleShowMenuBar()
699 const bool visible
= menuBar()->isVisible();
700 menuBar()->setVisible(!visible
);
703 void DolphinMainWindow::editSettings()
705 if (m_settingsDialog
== 0) {
706 const KUrl
& url
= activeViewContainer()->url();
707 m_settingsDialog
= new DolphinSettingsDialog(url
, this);
708 m_settingsDialog
->setAttribute(Qt::WA_DeleteOnClose
);
709 m_settingsDialog
->show();
711 m_settingsDialog
->raise();
715 void DolphinMainWindow::setActiveTab(int index
)
717 Q_ASSERT(index
>= 0);
718 Q_ASSERT(index
< m_viewTab
.count());
719 if (index
== m_tabIndex
) {
723 // hide current tab content
724 ViewTab
& hiddenTab
= m_viewTab
[m_tabIndex
];
725 hiddenTab
.isPrimaryViewActive
= hiddenTab
.primaryView
->isActive();
726 hiddenTab
.primaryView
->setActive(false);
727 if (hiddenTab
.secondaryView
!= 0) {
728 hiddenTab
.secondaryView
->setActive(false);
730 QSplitter
* splitter
= m_viewTab
[m_tabIndex
].splitter
;
732 m_centralWidgetLayout
->removeWidget(splitter
);
734 // show active tab content
737 ViewTab
& viewTab
= m_viewTab
[index
];
738 m_centralWidgetLayout
->addWidget(viewTab
.splitter
);
739 viewTab
.primaryView
->show();
740 if (viewTab
.secondaryView
!= 0) {
741 viewTab
.secondaryView
->show();
743 viewTab
.splitter
->show();
745 setActiveViewContainer(viewTab
.isPrimaryViewActive
? viewTab
.primaryView
:
746 viewTab
.secondaryView
);
749 void DolphinMainWindow::closeTab()
751 closeTab(m_tabBar
->currentIndex());
754 void DolphinMainWindow::closeTab(int index
)
756 Q_ASSERT(index
>= 0);
757 Q_ASSERT(index
< m_viewTab
.count());
758 if (m_viewTab
.count() == 1) {
759 // the last tab may never get closed
763 if (index
== m_tabIndex
) {
764 // The tab that should be closed is the active tab. Activate the
765 // previous tab before closing the tab.
766 m_tabBar
->setCurrentIndex((index
> 0) ? index
- 1 : 1);
770 m_viewTab
[index
].primaryView
->deleteLater();
771 if (m_viewTab
[index
].secondaryView
!= 0) {
772 m_viewTab
[index
].secondaryView
->deleteLater();
774 m_viewTab
[index
].splitter
->deleteLater();
775 m_viewTab
.erase(m_viewTab
.begin() + index
);
777 m_tabBar
->blockSignals(true);
778 m_tabBar
->removeTab(index
);
780 if (m_tabIndex
> index
) {
782 Q_ASSERT(m_tabIndex
>= 0);
785 // if only one tab is left, also remove the tab entry so that
786 // closing the last tab is not possible
787 if (m_viewTab
.count() == 1) {
788 m_tabBar
->removeTab(0);
789 actionCollection()->action("close_tab")->setEnabled(false);
791 m_tabBar
->blockSignals(false);
795 void DolphinMainWindow::openTabContextMenu(int index
, const QPoint
& pos
)
799 QAction
* newTabAction
= menu
.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
800 newTabAction
->setShortcut(actionCollection()->action("new_tab")->shortcut());
802 QAction
* closeOtherTabsAction
= menu
.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
804 QAction
* closeTabAction
= menu
.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
805 closeTabAction
->setShortcut(actionCollection()->action("close_tab")->shortcut());
807 QAction
* selectedAction
= menu
.exec(pos
);
808 if (selectedAction
== newTabAction
) {
809 const ViewTab
& tab
= m_viewTab
[index
];
810 Q_ASSERT(tab
.primaryView
!= 0);
811 const KUrl url
= (tab
.secondaryView
!= 0) && tab
.secondaryView
->isActive() ?
812 tab
.secondaryView
->url() : tab
.primaryView
->url();
814 m_tabBar
->setCurrentIndex(m_viewTab
.count() - 1);
815 } else if (selectedAction
== closeOtherTabsAction
) {
816 const int count
= m_tabBar
->count();
817 for (int i
= 0; i
< index
; ++i
) {
820 for (int i
= index
+ 1; i
< count
; ++i
) {
823 } else if (selectedAction
== closeTabAction
) {
828 void DolphinMainWindow::handlePlacesClick(const KUrl
& url
, Qt::MouseButtons buttons
)
830 if (buttons
& Qt::MidButton
) {
832 m_tabBar
->setCurrentIndex(m_viewTab
.count() - 1);
838 void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent
* event
, bool& canDecode
)
840 canDecode
= KUrl::List::canDecode(event
->mimeData());
843 void DolphinMainWindow::init()
845 DolphinSettings
& settings
= DolphinSettings::instance();
847 // Check whether Dolphin runs the first time. If yes then
848 // a proper default window size is given at the end of DolphinMainWindow::init().
849 GeneralSettings
* generalSettings
= settings
.generalSettings();
850 const bool firstRun
= generalSettings
->firstRun();
852 generalSettings
->setViewPropsTimestamp(QDateTime::currentDateTime());
855 setAcceptDrops(true);
857 m_viewTab
[m_tabIndex
].splitter
= new QSplitter(this);
861 const KUrl
& homeUrl
= generalSettings
->homeUrl();
862 setCaption(homeUrl
.fileName());
863 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
864 connect(m_actionHandler
, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
865 ViewProperties
props(homeUrl
);
866 m_viewTab
[m_tabIndex
].primaryView
= new DolphinViewContainer(this,
867 m_viewTab
[m_tabIndex
].splitter
,
870 m_activeViewContainer
= m_viewTab
[m_tabIndex
].primaryView
;
871 connectViewSignals(m_activeViewContainer
);
872 DolphinView
* view
= m_activeViewContainer
->view();
874 m_activeViewContainer
->show();
875 m_actionHandler
->setCurrentView(view
);
877 m_tabBar
= new KTabBar(this);
878 m_tabBar
->setCloseButtonEnabled(true);
879 connect(m_tabBar
, SIGNAL(currentChanged(int)),
880 this, SLOT(setActiveTab(int)));
881 connect(m_tabBar
, SIGNAL(closeRequest(int)),
882 this, SLOT(closeTab(int)));
883 connect(m_tabBar
, SIGNAL(contextMenu(int, const QPoint
&)),
884 this, SLOT(openTabContextMenu(int, const QPoint
&)));
885 connect(m_tabBar
, SIGNAL(newTabRequest()),
886 this, SLOT(openNewTab()));
887 connect(m_tabBar
, SIGNAL(testCanDecode(const QDragMoveEvent
*, bool&)),
888 this, SLOT(slotTestCanDecode(const QDragMoveEvent
*, bool&)));
889 m_tabBar
->blockSignals(true); // signals get unblocked after at least 2 tabs are open
891 QWidget
* centralWidget
= new QWidget(this);
892 m_centralWidgetLayout
= new QVBoxLayout(centralWidget
);
893 m_centralWidgetLayout
->setSpacing(0);
894 m_centralWidgetLayout
->setMargin(0);
895 m_centralWidgetLayout
->addWidget(m_tabBar
);
896 m_centralWidgetLayout
->addWidget(m_viewTab
[m_tabIndex
].splitter
);
898 setCentralWidget(centralWidget
);
900 emit
urlChanged(homeUrl
);
902 setupGUI(Keys
| Save
| Create
| ToolBar
);
904 stateChanged("new_file");
906 QClipboard
* clipboard
= QApplication::clipboard();
907 connect(clipboard
, SIGNAL(dataChanged()),
908 this, SLOT(updatePasteAction()));
912 if (generalSettings
->splitView()) {
917 QAction
* showFilterBarAction
= actionCollection()->action("show_filter_bar");
918 showFilterBarAction
->setChecked(generalSettings
->filterBar());
921 // assure a proper default size if Dolphin runs the first time
925 m_showMenuBar
->setChecked(!menuBar()->isHidden()); // workaround for bug #171080
928 void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer
* viewContainer
)
930 Q_ASSERT(viewContainer
!= 0);
931 Q_ASSERT((viewContainer
== m_viewTab
[m_tabIndex
].primaryView
) ||
932 (viewContainer
== m_viewTab
[m_tabIndex
].secondaryView
));
933 if (m_activeViewContainer
== viewContainer
) {
937 m_activeViewContainer
->setActive(false);
938 m_activeViewContainer
= viewContainer
;
940 // Activating the view container might trigger a recursive setActiveViewContainer() call
941 // inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary
942 // disconnect the activated() signal in this case:
943 disconnect(m_activeViewContainer
->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
944 m_activeViewContainer
->setActive(true);
945 connect(m_activeViewContainer
->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
947 m_actionHandler
->setCurrentView(viewContainer
->view());
954 const KUrl
& url
= m_activeViewContainer
->url();
955 setCaption(url
.fileName());
956 if (m_viewTab
.count() > 1) {
957 m_tabBar
->setTabText(m_tabIndex
, tabName(url
));
960 emit
urlChanged(url
);
963 void DolphinMainWindow::setupActions()
966 m_newMenu
= new DolphinNewMenu(this, this);
967 KMenu
* menu
= m_newMenu
->menu();
968 menu
->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
969 menu
->setIcon(KIcon("document-new"));
970 connect(menu
, SIGNAL(aboutToShow()),
971 this, SLOT(updateNewMenu()));
973 KAction
* newWindow
= actionCollection()->addAction("new_window");
974 newWindow
->setIcon(KIcon("window-new"));
975 newWindow
->setText(i18nc("@action:inmenu File", "New &Window"));
976 newWindow
->setShortcut(Qt::CTRL
| Qt::Key_N
);
977 connect(newWindow
, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
979 KAction
* newTab
= actionCollection()->addAction("new_tab");
980 newTab
->setIcon(KIcon("tab-new"));
981 newTab
->setText(i18nc("@action:inmenu File", "New Tab"));
982 newTab
->setShortcut(KShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_N
, Qt::CTRL
| Qt::Key_T
));
983 connect(newTab
, SIGNAL(triggered()), this, SLOT(openNewTab()));
985 QAction
* closeTab
= actionCollection()->addAction("close_tab");
986 closeTab
->setIcon(KIcon("tab-close"));
987 closeTab
->setText(i18nc("@action:inmenu File", "Close Tab"));
988 closeTab
->setShortcut(Qt::CTRL
| Qt::Key_W
);
989 closeTab
->setEnabled(false);
990 connect(closeTab
, SIGNAL(triggered()), this, SLOT(closeTab()));
992 KStandardAction::quit(this, SLOT(quit()), actionCollection());
995 KStandardAction::undo(this,
999 // need to remove shift+del from cut action, else the shortcut for deletejob
1001 KAction
* cut
= KStandardAction::cut(this, SLOT(cut()), actionCollection());
1002 KShortcut cutShortcut
= cut
->shortcut();
1003 cutShortcut
.remove(Qt::SHIFT
+ Qt::Key_Delete
, KShortcut::KeepEmpty
);
1004 cut
->setShortcut(cutShortcut
);
1005 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1006 KStandardAction::paste(this, SLOT(paste()), actionCollection());
1008 KAction
* selectAll
= actionCollection()->addAction("select_all");
1009 selectAll
->setText(i18nc("@action:inmenu Edit", "Select All"));
1010 selectAll
->setShortcut(Qt::CTRL
+ Qt::Key_A
);
1011 connect(selectAll
, SIGNAL(triggered()), this, SLOT(selectAll()));
1013 KAction
* invertSelection
= actionCollection()->addAction("invert_selection");
1014 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
1015 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1016 connect(invertSelection
, SIGNAL(triggered()), this, SLOT(invertSelection()));
1018 // setup 'View' menu
1019 // (note that most of it is set up in DolphinViewActionHandler)
1021 KAction
* split
= actionCollection()->addAction("split_view");
1022 split
->setShortcut(Qt::Key_F3
);
1023 updateSplitAction();
1024 connect(split
, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1026 KAction
* reload
= actionCollection()->addAction("reload");
1027 reload
->setText(i18nc("@action:inmenu View", "Reload"));
1028 reload
->setShortcut(Qt::Key_F5
);
1029 reload
->setIcon(KIcon("view-refresh"));
1030 connect(reload
, SIGNAL(triggered()), this, SLOT(reloadView()));
1032 KAction
* stop
= actionCollection()->addAction("stop");
1033 stop
->setText(i18nc("@action:inmenu View", "Stop"));
1034 stop
->setIcon(KIcon("process-stop"));
1035 connect(stop
, SIGNAL(triggered()), this, SLOT(stopLoading()));
1037 KToggleAction
* showFullLocation
= actionCollection()->add
<KToggleAction
>("editable_location");
1038 showFullLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
1039 showFullLocation
->setShortcut(Qt::CTRL
| Qt::Key_L
);
1040 connect(showFullLocation
, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1042 KAction
* replaceLocation
= actionCollection()->addAction("replace_location");
1043 replaceLocation
->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
1044 replaceLocation
->setShortcut(Qt::Key_F6
);
1045 connect(replaceLocation
, SIGNAL(triggered()), this, SLOT(replaceLocation()));
1048 KAction
* backAction
= KStandardAction::back(this, SLOT(goBack()), actionCollection());
1049 KShortcut backShortcut
= backAction
->shortcut();
1050 backShortcut
.setAlternate(Qt::Key_Backspace
);
1051 backAction
->setShortcut(backShortcut
);
1053 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1054 KStandardAction::up(this, SLOT(goUp()), actionCollection());
1055 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1057 // setup 'Tools' menu
1058 KToggleAction
* showFilterBar
= actionCollection()->add
<KToggleAction
>("show_filter_bar");
1059 showFilterBar
->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
1060 showFilterBar
->setShortcut(Qt::CTRL
| Qt::Key_I
);
1061 connect(showFilterBar
, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
1063 KAction
* compareFiles
= actionCollection()->addAction("compare_files");
1064 compareFiles
->setText(i18nc("@action:inmenu Tools", "Compare Files"));
1065 compareFiles
->setIcon(KIcon("kompare"));
1066 compareFiles
->setEnabled(false);
1067 connect(compareFiles
, SIGNAL(triggered()), this, SLOT(compareFiles()));
1069 // disabled Quick View
1070 #if defined(QUICK_VIEW)
1071 KAction
* quickView
= actionCollection()->addAction("quick_view");
1072 quickView
->setText(i18nc("@action:inmenu Tools", "Quick View"));
1073 quickView
->setIcon(KIcon("view-preview"));
1074 quickView
->setShortcut(Qt::CTRL
+ Qt::Key_Return
);
1075 quickView
->setEnabled(false);
1076 connect(quickView
, SIGNAL(triggered()), this, SLOT(quickView()));
1079 // setup 'Settings' menu
1080 m_showMenuBar
= KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
1081 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1083 // not in menu actions
1084 KAction
* activateNextTab
= actionCollection()->addAction("activate_next_tab");
1085 activateNextTab
->setText(i18nc("@action:inmenu", "Activate Next Tab"));
1086 connect(activateNextTab
, SIGNAL(triggered()), SLOT(activateNextTab()));
1087 activateNextTab
->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() :
1088 KStandardShortcut::tabNext());
1090 KAction
* activatePrevTab
= actionCollection()->addAction("activate_prev_tab");
1091 activatePrevTab
->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
1092 connect(activatePrevTab
, SIGNAL(triggered()), SLOT(activatePrevTab()));
1093 activatePrevTab
->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() :
1094 KStandardShortcut::tabPrev());
1097 KAction
* openInNewTab
= actionCollection()->addAction("open_in_new_tab");
1098 openInNewTab
->setText(i18nc("@action:inmenu", "Open in New Tab"));
1099 openInNewTab
->setIcon(KIcon("tab-new"));
1100 connect(openInNewTab
, SIGNAL(triggered()), this, SLOT(openInNewTab()));
1102 KAction
* openInNewWindow
= actionCollection()->addAction("open_in_new_window");
1103 openInNewWindow
->setText(i18nc("@action:inmenu", "Open in New Window"));
1104 openInNewWindow
->setIcon(KIcon("window-new"));
1105 connect(openInNewWindow
, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
1108 void DolphinMainWindow::setupDockWidgets()
1110 // setup "Information"
1111 QDockWidget
* infoDock
= new QDockWidget(i18nc("@title:window", "Information"));
1112 infoDock
->setObjectName("infoDock");
1113 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1114 Panel
* infoPanel
= new InformationPanel(infoDock
);
1115 infoDock
->setWidget(infoPanel
);
1117 QAction
* infoAction
= infoDock
->toggleViewAction();
1118 infoAction
->setText(i18nc("@title:window", "Information"));
1119 infoAction
->setShortcut(Qt::Key_F11
);
1120 infoAction
->setIcon(KIcon("dialog-information"));
1121 actionCollection()->addAction("show_info_panel", infoDock
->toggleViewAction());
1123 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1124 connect(this, SIGNAL(urlChanged(KUrl
)),
1125 infoPanel
, SLOT(setUrl(KUrl
)));
1126 connect(this, SIGNAL(selectionChanged(KFileItemList
)),
1127 infoPanel
, SLOT(setSelection(KFileItemList
)));
1128 connect(this, SIGNAL(requestItemInfo(KFileItem
)),
1129 infoPanel
, SLOT(requestDelayedItemInfo(KFileItem
)));
1132 QDockWidget
* foldersDock
= new QDockWidget(i18nc("@title:window", "Folders"));
1133 foldersDock
->setObjectName("foldersDock");
1134 foldersDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1135 FoldersPanel
* foldersPanel
= new FoldersPanel(foldersDock
);
1136 foldersDock
->setWidget(foldersPanel
);
1138 QAction
* foldersAction
= foldersDock
->toggleViewAction();
1139 foldersAction
->setText(i18nc("@title:window", "Folders"));
1140 foldersAction
->setShortcut(Qt::Key_F7
);
1141 foldersAction
->setIcon(KIcon("folder"));
1142 actionCollection()->addAction("show_folders_panel", foldersDock
->toggleViewAction());
1144 addDockWidget(Qt::LeftDockWidgetArea
, foldersDock
);
1145 connect(this, SIGNAL(urlChanged(KUrl
)),
1146 foldersPanel
, SLOT(setUrl(KUrl
)));
1147 connect(foldersPanel
, SIGNAL(changeUrl(KUrl
, Qt::MouseButtons
)),
1148 this, SLOT(handlePlacesClick(KUrl
, Qt::MouseButtons
)));
1149 connect(foldersPanel
, SIGNAL(changeSelection(KFileItemList
)),
1150 this, SLOT(changeSelection(KFileItemList
)));
1154 QDockWidget
* terminalDock
= new QDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1155 terminalDock
->setObjectName("terminalDock");
1156 terminalDock
->setAllowedAreas(Qt::TopDockWidgetArea
| Qt::BottomDockWidgetArea
);
1157 Panel
* terminalPanel
= new TerminalPanel(terminalDock
);
1158 terminalDock
->setWidget(terminalPanel
);
1160 connect(terminalPanel
, SIGNAL(hideTerminalPanel()), terminalDock
, SLOT(hide()));
1162 QAction
* terminalAction
= terminalDock
->toggleViewAction();
1163 terminalAction
->setText(i18nc("@title:window Shell terminal", "Terminal"));
1164 terminalAction
->setShortcut(Qt::Key_F4
);
1165 terminalAction
->setIcon(KIcon("terminal"));
1166 actionCollection()->addAction("show_terminal_panel", terminalDock
->toggleViewAction());
1168 addDockWidget(Qt::BottomDockWidgetArea
, terminalDock
);
1169 connect(this, SIGNAL(urlChanged(KUrl
)),
1170 terminalPanel
, SLOT(setUrl(KUrl
)));
1173 const bool firstRun
= DolphinSettings::instance().generalSettings()->firstRun();
1175 foldersDock
->hide();
1177 terminalDock
->hide();
1181 QDockWidget
* placesDock
= new QDockWidget(i18nc("@title:window", "Places"));
1182 placesDock
->setObjectName("placesDock");
1183 placesDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1185 PlacesPanel
* placesPanel
= new PlacesPanel(placesDock
);
1186 placesDock
->setWidget(placesPanel
);
1187 placesPanel
->setModel(DolphinSettings::instance().placesModel());
1188 placesPanel
->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff
);
1190 QAction
* placesAction
= placesDock
->toggleViewAction();
1191 placesAction
->setText(i18nc("@title:window", "Places"));
1192 placesAction
->setShortcut(Qt::Key_F9
);
1193 placesAction
->setIcon(KIcon("bookmarks"));
1194 actionCollection()->addAction("show_places_panel", placesDock
->toggleViewAction());
1196 addDockWidget(Qt::LeftDockWidgetArea
, placesDock
);
1197 connect(placesPanel
, SIGNAL(urlChanged(KUrl
, Qt::MouseButtons
)),
1198 this, SLOT(handlePlacesClick(KUrl
, Qt::MouseButtons
)));
1199 connect(this, SIGNAL(urlChanged(KUrl
)),
1200 placesPanel
, SLOT(setUrl(KUrl
)));
1203 void DolphinMainWindow::updateEditActions()
1205 const KFileItemList list
= m_activeViewContainer
->view()->selectedItems();
1206 if (list
.isEmpty()) {
1207 stateChanged("has_no_selection");
1209 stateChanged("has_selection");
1211 KActionCollection
* col
= actionCollection();
1212 QAction
* renameAction
= col
->action("rename");
1213 QAction
* moveToTrashAction
= col
->action("move_to_trash");
1214 QAction
* deleteAction
= col
->action("delete");
1215 QAction
* cutAction
= col
->action(KStandardAction::name(KStandardAction::Cut
));
1216 QAction
* deleteWithTrashShortcut
= col
->action("delete_shortcut"); // see DolphinViewActionHandler
1218 KonqFileItemCapabilities
capabilities(list
);
1219 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
1221 renameAction
->setEnabled(capabilities
.supportsMoving());
1222 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1223 deleteAction
->setEnabled(capabilities
.supportsDeleting());
1224 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
1225 cutAction
->setEnabled(capabilities
.supportsMoving());
1227 updatePasteAction();
1230 void DolphinMainWindow::updateViewActions()
1232 m_actionHandler
->updateViewActions();
1234 QAction
* showFilterBarAction
= actionCollection()->action("show_filter_bar");
1235 showFilterBarAction
->setChecked(m_activeViewContainer
->isFilterBarVisible());
1237 updateSplitAction();
1239 QAction
* editableLocactionAction
= actionCollection()->action("editable_location");
1240 const KUrlNavigator
* urlNavigator
= m_activeViewContainer
->urlNavigator();
1241 editableLocactionAction
->setChecked(urlNavigator
->isUrlEditable());
1244 void DolphinMainWindow::updateGoActions()
1246 QAction
* goUpAction
= actionCollection()->action(KStandardAction::name(KStandardAction::Up
));
1247 const KUrl
& currentUrl
= m_activeViewContainer
->url();
1248 goUpAction
->setEnabled(currentUrl
.upUrl() != currentUrl
);
1251 void DolphinMainWindow::clearStatusBar()
1253 m_activeViewContainer
->statusBar()->clear();
1256 void DolphinMainWindow::connectViewSignals(DolphinViewContainer
* container
)
1258 connect(container
, SIGNAL(showFilterBarChanged(bool)),
1259 this, SLOT(updateFilterBarAction(bool)));
1261 DolphinView
* view
= container
->view();
1262 connect(view
, SIGNAL(selectionChanged(KFileItemList
)),
1263 this, SLOT(slotSelectionChanged(KFileItemList
)));
1264 connect(view
, SIGNAL(requestItemInfo(KFileItem
)),
1265 this, SLOT(slotRequestItemInfo(KFileItem
)));
1266 connect(view
, SIGNAL(activated()),
1267 this, SLOT(toggleActiveView()));
1268 connect(view
, SIGNAL(tabRequested(const KUrl
&)),
1269 this, SLOT(openNewTab(const KUrl
&)));
1271 const KUrlNavigator
* navigator
= container
->urlNavigator();
1272 connect(navigator
, SIGNAL(urlChanged(const KUrl
&)),
1273 this, SLOT(changeUrl(const KUrl
&)));
1274 connect(navigator
, SIGNAL(historyChanged()),
1275 this, SLOT(updateHistory()));
1276 connect(navigator
, SIGNAL(editableStateChanged(bool)),
1277 this, SLOT(slotEditableStateChanged(bool)));
1280 void DolphinMainWindow::updateSplitAction()
1282 QAction
* splitAction
= actionCollection()->action("split_view");
1283 if (m_viewTab
[m_tabIndex
].secondaryView
!= 0) {
1284 if (m_activeViewContainer
== m_viewTab
[m_tabIndex
].secondaryView
) {
1285 splitAction
->setText(i18nc("@action:intoolbar Close right view", "Close"));
1286 splitAction
->setIcon(KIcon("view-right-close"));
1288 splitAction
->setText(i18nc("@action:intoolbar Close left view", "Close"));
1289 splitAction
->setIcon(KIcon("view-left-close"));
1292 splitAction
->setText(i18nc("@action:intoolbar Split view", "Split"));
1293 splitAction
->setIcon(KIcon("view-right-new"));
1297 QString
DolphinMainWindow::tabName(const KUrl
& url
) const
1300 if (url
.equals(KUrl("file:///"))) {
1303 name
= url
.fileName();
1304 if (name
.isEmpty()) {
1305 name
= url
.protocol();
1311 bool DolphinMainWindow::isKompareInstalled() const
1313 static bool initialized
= false;
1314 static bool installed
= false;
1316 // TODO: maybe replace this approach later by using a menu
1317 // plugin like kdiff3plugin.cpp
1318 installed
= !KGlobal::dirs()->findExe("kompare").isEmpty();
1324 void DolphinMainWindow::createSecondaryView(int tabIndex
)
1326 QSplitter
* splitter
= m_viewTab
[tabIndex
].splitter
;
1327 const int newWidth
= (m_viewTab
[tabIndex
].primaryView
->width() - splitter
->handleWidth()) / 2;
1329 const DolphinView
* view
= m_viewTab
[tabIndex
].primaryView
->view();
1330 m_viewTab
[tabIndex
].secondaryView
= new DolphinViewContainer(this, 0, view
->rootUrl());
1331 splitter
->addWidget(m_viewTab
[tabIndex
].secondaryView
);
1332 splitter
->setSizes(QList
<int>() << newWidth
<< newWidth
);
1333 connectViewSignals(m_viewTab
[tabIndex
].secondaryView
);
1334 m_viewTab
[tabIndex
].secondaryView
->view()->reload();
1335 m_viewTab
[tabIndex
].secondaryView
->setActive(false);
1336 m_viewTab
[tabIndex
].secondaryView
->show();
1339 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
1340 KIO::FileUndoManager::UiInterface()
1344 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1348 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job
* job
)
1350 DolphinMainWindow
* mainWin
= qobject_cast
<DolphinMainWindow
*>(parentWidget());
1352 DolphinStatusBar
* statusBar
= mainWin
->activeViewContainer()->statusBar();
1353 statusBar
->setMessage(job
->errorString(), DolphinStatusBar::Error
);
1355 KIO::FileUndoManager::UiInterface::jobError(job
);
1359 #include "dolphinmainwindow.moc"