]>
cloud.milkyroute.net Git - dolphin.git/blob - 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> *
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"
26 #include "dolphinapplication.h"
27 #include "dolphinsettings.h"
28 #include "dolphinsettingsdialog.h"
29 #include "dolphinstatusbar.h"
30 #include "dolphinapplication.h"
31 #include "urlnavigator.h"
32 #include "progressindicator.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"
41 #include <kactioncollection.h>
42 #include <kbookmarkmanager.h>
44 #include <kdesktopfile.h>
45 #include <kdeversion.h>
46 #include <kfiledialog.h>
49 #include <kiconloader.h>
50 #include <kio/netaccess.h>
51 #include <kio/renamedialog.h>
52 #include <kinputdialog.h>
55 #include <kmessagebox.h>
56 #include <konqmimedata.h>
57 #include <konq_undo.h>
58 #include <kpropertiesdialog.h>
59 #include <kprotocolinfo.h>
60 #include <ktoggleaction.h>
63 #include <kstandarddirs.h>
64 #include <kstatusbar.h>
65 #include <kstandardaction.h>
68 #include <Q3ValueList> // TODO
69 #include <QCloseEvent>
72 #include <QDockWidget>
74 DolphinMainWindow::DolphinMainWindow() :
79 setObjectName("Dolphin");
80 m_view
[PrimaryIdx
] = 0;
81 m_view
[SecondaryIdx
] = 0;
83 KonqUndoManager::incRef();
85 connect(KonqUndoManager::self(), SIGNAL(undoAvailable(bool)),
86 this, SLOT(slotUndoAvailable(bool)));
87 connect(KonqUndoManager::self(), SIGNAL(undoTextChanged(const QString
&)),
88 this, SLOT(slotUndoTextChanged(const QString
&)));
91 DolphinMainWindow::~DolphinMainWindow()
93 KonqUndoManager::decRef();
95 qDeleteAll(m_fileGroupActions
);
96 m_fileGroupActions
.clear();
98 DolphinApplication::app()->removeMainWindow(this);
101 void DolphinMainWindow::setActiveView(DolphinView
* view
)
103 assert((view
== m_view
[PrimaryIdx
]) || (view
== m_view
[SecondaryIdx
]));
104 if (m_activeView
== view
) {
115 setCaption(m_activeView
->url().fileName());
117 emit
activeViewChanged();
120 void DolphinMainWindow::dropUrls(const KUrl::List
& urls
,
121 const KUrl
& destination
)
123 m_dropDestination
= destination
;
124 m_droppedUrls
= urls
;
127 const ButtonState keyboardState = KApplication::keyboardMouseState();
128 const bool shiftPressed = (keyboardState & ShiftButton) > 0;
129 const bool controlPressed = (keyboardState & ControlButton) > 0;
133 if (shiftPressed && controlPressed) {
134 // shortcut for 'Linke Here' is used
137 else if (controlPressed) {
138 // shortcut for 'Copy Here' is used
141 else if (shiftPressed) {
142 // shortcut for 'Move Here' is used
146 // no shortcut is used, hence open a popup menu
149 QAction
* moveAction
= popup
.addAction(SmallIcon("goto"), i18n("&Move Here"));
150 connect(moveAction
, SIGNAL(triggered()), this, SLOT(moveDroppedItems()));
152 QAction
* copyAction
= popup
.addAction(SmallIcon("editcopy"), i18n( "&Copy Here" ));
153 connect(copyAction
, SIGNAL(triggered()), this, SLOT(copyDroppedItems()));
155 QAction
* linkAction
= popup
.addAction(i18n("&Link Here"));
156 connect(linkAction
, SIGNAL(triggered()), this, SLOT(linkDroppedItems()));
158 QAction
* cancelAction
= popup
.addAction(SmallIcon("stop"), i18n("Cancel"));
159 popup
.insertSeparator(cancelAction
);
161 popup
.exec(QCursor::pos());
164 m_droppedUrls
.clear();
167 void DolphinMainWindow::refreshViews()
169 const bool split
= DolphinSettings::instance().generalSettings()->splitView();
170 const bool isPrimaryViewActive
= (m_activeView
== m_view
[PrimaryIdx
]);
172 for (int i
= PrimaryIdx
; i
<= SecondaryIdx
; ++i
) {
173 if (m_view
[i
] != 0) {
174 url
= m_view
[i
]->url();
176 // delete view instance...
178 m_view
[i
]->deleteLater();
182 if (split
|| (i
== PrimaryIdx
)) {
183 // ... and recreate it
184 ViewProperties
props(url
);
185 m_view
[i
] = new DolphinView(this,
189 props
.showHiddenFiles());
190 connectViewSignals(i
);
195 m_activeView
= isPrimaryViewActive
? m_view
[PrimaryIdx
] : m_view
[SecondaryIdx
];
196 assert(m_activeView
!= 0);
199 emit
activeViewChanged();
202 void DolphinMainWindow::slotViewModeChanged()
207 void DolphinMainWindow::slotShowHiddenFilesChanged()
209 KToggleAction
* showHiddenFilesAction
=
210 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
211 showHiddenFilesAction
->setChecked(m_activeView
->showHiddenFiles());
214 void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting
)
218 case DolphinView::SortByName
:
219 action
= actionCollection()->action("by_name");
221 case DolphinView::SortBySize
:
222 action
= actionCollection()->action("by_size");
224 case DolphinView::SortByDate
:
225 action
= actionCollection()->action("by_date");
232 KToggleAction
* toggleAction
= static_cast<KToggleAction
*>(action
);
233 toggleAction
->setChecked(true);
237 void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order
)
239 KToggleAction
* descending
= static_cast<KToggleAction
*>(actionCollection()->action("descending"));
240 const bool sortDescending
= (order
== Qt::Descending
);
241 descending
->setChecked(sortDescending
);
244 void DolphinMainWindow::slotSelectionChanged()
248 assert(m_view
[PrimaryIdx
] != 0);
249 int selectedUrlsCount
= m_view
[PrimaryIdx
]->selectedUrls().count();
250 if (m_view
[SecondaryIdx
] != 0) {
251 selectedUrlsCount
+= m_view
[SecondaryIdx
]->selectedUrls().count();
254 QAction
* compareFilesAction
= actionCollection()->action("compare_files");
255 compareFilesAction
->setEnabled(selectedUrlsCount
== 2);
257 m_activeView
->updateStatusBar();
259 emit
selectionChanged();
262 void DolphinMainWindow::slotHistoryChanged()
267 void DolphinMainWindow::slotUrlChanged(const KUrl
& url
)
271 setCaption(url
.fileName());
274 void DolphinMainWindow::updateFilterBarAction(bool show
)
276 KToggleAction
* showFilterBarAction
=
277 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
278 showFilterBarAction
->setChecked(show
);
281 void DolphinMainWindow::openNewMainWindow()
283 DolphinApplication::app()->createMainWindow()->show();
286 void DolphinMainWindow::moveDroppedItems()
288 moveUrls(m_droppedUrls
, m_dropDestination
);
291 void DolphinMainWindow::copyDroppedItems()
293 copyUrls(m_droppedUrls
, m_dropDestination
);
296 void DolphinMainWindow::linkDroppedItems()
298 KonqOperations::copy(this, KonqOperations::LINK
, m_droppedUrls
, m_dropDestination
);
299 m_undoOperations
.append(KonqOperations::LINK
);
302 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
304 DolphinSettings
& settings
= DolphinSettings::instance();
305 GeneralSettings
* generalSettings
= settings
.generalSettings();
306 generalSettings
->setFirstRun(false);
310 // TODO: I assume there will be a generic way in KDE 4 to store the docks
311 // of the main window. In the meantime they are stored manually:
312 QString filename
= KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName());
313 filename
.append("/panels_layout");
314 QFile
file(filename
);
315 if (file
.open(QIODevice::WriteOnly
)) {
316 QByteArray data
= saveState();
321 KMainWindow::closeEvent(event
);
324 void DolphinMainWindow::saveProperties(KConfig
* config
)
326 config
->setGroup("Primary view");
327 config
->writeEntry("Url", m_view
[PrimaryIdx
]->url().url());
328 config
->writeEntry("Editable Url", m_view
[PrimaryIdx
]->isUrlEditable());
329 if (m_view
[SecondaryIdx
] != 0) {
330 config
->setGroup("Secondary view");
331 config
->writeEntry("Url", m_view
[SecondaryIdx
]->url().url());
332 config
->writeEntry("Editable Url", m_view
[SecondaryIdx
]->isUrlEditable());
336 void DolphinMainWindow::readProperties(KConfig
* config
)
338 config
->setGroup("Primary view");
339 m_view
[PrimaryIdx
]->setUrl(config
->readEntry("Url"));
340 m_view
[PrimaryIdx
]->setUrlEditable(config
->readEntry("Editable Url", false));
341 if (config
->hasGroup("Secondary view")) {
342 config
->setGroup("Secondary view");
343 if (m_view
[SecondaryIdx
] == 0) {
346 m_view
[SecondaryIdx
]->setUrl(config
->readEntry("Url"));
347 m_view
[SecondaryIdx
]->setUrlEditable(config
->readEntry("Editable Url", false));
349 else if (m_view
[SecondaryIdx
] != 0) {
354 void DolphinMainWindow::createFolder()
356 // Parts of the following code have been taken
357 // from the class KonqPopupMenu located in
358 // libqonq/konq_popupmenu.h of Konqueror.
359 // (Copyright (C) 2000 David Faure <faure@kde.org>,
360 // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
364 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
365 const KUrl
baseUrl(m_activeView
->url());
367 QString
name(i18n("New Folder"));
368 baseUrl
.path(KUrl::AddTrailingSlash
);
371 if (baseUrl
.isLocalFile() && QFileInfo(baseUrl
.path(KUrl::AddTrailingSlash
) + name
).exists()) {
372 name
= KIO::RenameDialog::suggestName(baseUrl
, i18n("New Folder"));
376 name
= KInputDialog::getText(i18n("New Folder"),
377 i18n("Enter folder name:" ),
383 // the user has pressed 'Cancel'
387 assert(!name
.isEmpty());
390 if ((name
[0] == '/') || (name
[0] == '~')) {
391 url
.setPath(KShell::tildeExpand(name
));
394 name
= KIO::encodeFileName(name
);
399 KonqOperations::mkdir(this, url
);
401 // TODO: is there a possability to check whether the mkdir operation
402 // has been successful?
404 statusBar
->setMessage(i18n("Created folder %1.",url
.path()),
405 DolphinStatusBar::OperationCompleted
);
408 // // Creating of the folder has been failed. Check whether the creating
409 // // has been failed because a folder with the same name exists...
410 // if (KIO::NetAccess::exists(url, true, this)) {
411 // statusBar->setMessage(i18n("A folder named %1 already exists.",url.path()),
412 // DolphinStatusBar::Error);
415 // statusBar->setMessage(i18n("Creating of folder %1 failed.",url.path()),
416 // DolphinStatusBar::Error);
420 void DolphinMainWindow::createFile()
422 // Parts of the following code have been taken
423 // from the class KonqPopupMenu located in
424 // libqonq/konq_popupmenu.h of Konqueror.
425 // (Copyright (C) 2000 David Faure <faure@kde.org>,
426 // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
430 // TODO: const Entry& entry = m_createFileTemplates[QString(sender->name())];
431 // should be enough. Anyway: the implementation of [] does a linear search internally too.
432 KSortableList
<CreateFileEntry
, QString
>::ConstIterator it
= m_createFileTemplates
.begin();
433 KSortableList
<CreateFileEntry
, QString
>::ConstIterator end
= m_createFileTemplates
.end();
435 const QString
senderName(sender()->objectName());
437 CreateFileEntry entry
;
438 while (!found
&& (it
!= end
)) {
439 if ((*it
).key() == senderName
) {
440 entry
= (*it
).value();
448 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
449 if (!found
|| !QFile::exists(entry
.templatePath
)) {
450 statusBar
->setMessage(i18n("Could not create file."), DolphinStatusBar::Error
);
454 // Get the source path of the template which should be copied.
455 // The source path is part of the Url entry of the desktop file.
456 const int pos
= entry
.templatePath
.lastIndexOf('/');
457 QString
sourcePath(entry
.templatePath
.left(pos
+ 1));
458 sourcePath
+= KDesktopFile(entry
.templatePath
, true).readPathEntry("Url");
460 QString
name(i18n(entry
.name
.toAscii()));
461 // Most entry names end with "..." (e. g. "HTML File..."), which is ok for
462 // menus but no good choice for a new file name -> remove the dots...
463 name
.replace("...", QString::null
);
465 // add the file extension to the name
466 name
.append(sourcePath
.right(sourcePath
.length() - sourcePath
.lastIndexOf('.')));
468 // Check whether a file with the current name already exists. If yes suggest automatically
469 // a unique file name (e. g. "HTML File" will be replaced by "HTML File_1").
470 const KUrl
viewUrl(m_activeView
->url());
471 const bool fileExists
= viewUrl
.isLocalFile() &&
472 QFileInfo(viewUrl
.path(KUrl::AddTrailingSlash
) + KIO::encodeFileName(name
)).exists();
474 name
= KIO::RenameDialog::suggestName(viewUrl
, name
);
477 // let the user change the suggested file name
479 name
= KInputDialog::getText(entry
.name
,
485 // the user has pressed 'Cancel'
489 // before copying the template to the destination path check whether a file
490 // with the given name already exists
491 const QString
destPath(viewUrl
.pathOrUrl() + "/" + KIO::encodeFileName(name
));
492 const KUrl
destUrl(destPath
);
493 if (KIO::NetAccess::exists(destUrl
, false, this)) {
494 statusBar
->setMessage(i18n("A file named %1 already exists.",name
),
495 DolphinStatusBar::Error
);
499 // copy the template to the destination path
500 const KUrl
sourceUrl(sourcePath
);
501 KIO::CopyJob
* job
= KIO::copyAs(sourceUrl
, destUrl
);
502 job
->setDefaultPermissions(true);
503 if (KIO::NetAccess::synchronousRun(job
, this)) {
504 statusBar
->setMessage(i18n("Created file %1.",name
),
505 DolphinStatusBar::OperationCompleted
);
508 list
.append(sourceUrl
);
510 // TODO: use the KonqUndoManager/KonqOperations instead.
511 //DolphinCommand command(DolphinCommand::CreateFile, list, destUrl);
512 //UndoManager::instance().addCommand(command);
516 statusBar
->setMessage(i18n("Creating of file %1 failed.",name
),
517 DolphinStatusBar::Error
);
521 void DolphinMainWindow::rename()
524 m_activeView
->renameSelectedItems();
527 void DolphinMainWindow::moveToTrash()
530 const KUrl::List selectedUrls
= m_activeView
->selectedUrls();
531 // TODO: per default a message box is opened which asks whether the item
532 // should really be moved to the trash. This does not make sense, as the
533 // action can be undone anyway by the user.
534 KonqOperations::del(this, KonqOperations::TRASH
, selectedUrls
);
535 m_undoOperations
.append(KonqOperations::TRASH
);
538 void DolphinMainWindow::deleteItems()
542 KUrl::List list
= m_activeView
->selectedUrls();
543 const uint itemCount
= list
.count();
544 assert(itemCount
>= 1);
548 text
= i18n("Do you really want to delete the %1 selected items?",itemCount
);
551 const KUrl
& url
= list
.first();
552 text
= i18n("Do you really want to delete '%1'?",url
.fileName());
555 const bool del
= KMessageBox::warningContinueCancel(this,
558 KGuiItem(i18n("Delete"), KIcon("editdelete"))
559 ) == KMessageBox::Continue
;
561 KIO::Job
* job
= KIO::del(list
);
562 connect(job
, SIGNAL(result(KJob
*)),
563 this, SLOT(slotHandleJobError(KJob
*)));
564 connect(job
, SIGNAL(result(KJob
*)),
565 this, SLOT(slotDeleteFileFinished(KJob
*)));
569 void DolphinMainWindow::properties()
571 const KFileItemList list
= m_activeView
->selectedItems();
572 new KPropertiesDialog(list
, this);
575 void DolphinMainWindow::quit()
580 void DolphinMainWindow::slotHandleJobError(KJob
* job
)
582 if (job
->error() != 0) {
583 m_activeView
->statusBar()->setMessage(job
->errorString(),
584 DolphinStatusBar::Error
);
588 void DolphinMainWindow::slotDeleteFileFinished(KJob
* job
)
590 if (job
->error() == 0) {
591 m_activeView
->statusBar()->setMessage(i18n("Delete operation completed."),
592 DolphinStatusBar::OperationCompleted
);
594 // TODO: In opposite to the 'Move to Trash' operation in the class KFileIconView
595 // no rearranging of the item position is done when a file has been deleted.
596 // This is bypassed by reloading the view, but it might be worth to investigate
597 // deeper for the root of this issue.
598 m_activeView
->reload();
602 void DolphinMainWindow::slotUndoAvailable(bool available
)
604 QAction
* undoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo
));
605 if (undoAction
!= 0) {
606 undoAction
->setEnabled(available
);
609 if (available
&& (m_undoOperations
.count() > 0)) {
610 const KonqOperations::Operation op
= m_undoOperations
.takeFirst();
611 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
613 case KonqOperations::COPY
:
614 statusBar
->setMessage(i18n("Copy operation completed."),
615 DolphinStatusBar::OperationCompleted
);
617 case KonqOperations::MOVE
:
618 statusBar
->setMessage(i18n("Move operation completed."),
619 DolphinStatusBar::OperationCompleted
);
621 case KonqOperations::LINK
:
622 statusBar
->setMessage(i18n("Link operation completed."),
623 DolphinStatusBar::OperationCompleted
);
625 case KonqOperations::TRASH
:
626 statusBar
->setMessage(i18n("Move to trash operation completed."),
627 DolphinStatusBar::OperationCompleted
);
636 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
638 QAction
* undoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo
));
639 if (undoAction
!= 0) {
640 undoAction
->setText(text
);
644 void DolphinMainWindow::cut()
646 QMimeData
* mimeData
= new QMimeData();
647 const KUrl::List kdeUrls
= m_activeView
->selectedUrls();
648 const KUrl::List mostLocalUrls
;
649 KonqMimeData::populateMimeData(mimeData
, kdeUrls
, mostLocalUrls
, true);
650 QApplication::clipboard()->setMimeData(mimeData
);
653 void DolphinMainWindow::copy()
655 QMimeData
* mimeData
= new QMimeData();
656 const KUrl::List kdeUrls
= m_activeView
->selectedUrls();
657 const KUrl::List mostLocalUrls
;
658 KonqMimeData::populateMimeData(mimeData
, kdeUrls
, mostLocalUrls
, false);
660 QApplication::clipboard()->setMimeData(mimeData
);
663 void DolphinMainWindow::paste()
665 QClipboard
* clipboard
= QApplication::clipboard();
666 const QMimeData
* mimeData
= clipboard
->mimeData();
670 const KUrl::List sourceUrls
= KUrl::List::fromMimeData(mimeData
);
672 // per default the pasting is done into the current Url of the view
673 KUrl
destUrl(m_activeView
->url());
675 // check whether the pasting should be done into a selected directory
676 KUrl::List selectedUrls
= m_activeView
->selectedUrls();
677 if (selectedUrls
.count() == 1) {
678 const KFileItem
fileItem(S_IFDIR
,
680 selectedUrls
.first(),
682 if (fileItem
.isDir()) {
683 // only one item is selected which is a directory, hence paste
684 // into this directory
685 destUrl
= selectedUrls
.first();
689 if (KonqMimeData::decodeIsCutSelection(mimeData
)) {
690 moveUrls(sourceUrls
, destUrl
);
694 copyUrls(sourceUrls
, destUrl
);
698 void DolphinMainWindow::updatePasteAction()
700 QAction
* pasteAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste
));
701 if (pasteAction
== 0) {
705 QString
text(i18n("Paste"));
706 QClipboard
* clipboard
= QApplication::clipboard();
707 const QMimeData
* mimeData
= clipboard
->mimeData();
709 KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
710 if (!urls
.isEmpty()) {
711 pasteAction
->setEnabled(true);
713 const int count
= urls
.count();
715 pasteAction
->setText(i18n("Paste 1 File"));
718 pasteAction
->setText(i18n("Paste %1 Files").arg(count
));
722 pasteAction
->setEnabled(false);
723 pasteAction
->setText(i18n("Paste"));
726 if (pasteAction
->isEnabled()) {
727 KUrl::List urls
= m_activeView
->selectedUrls();
728 const uint count
= urls
.count();
730 // pasting should not be allowed when more than one file
732 pasteAction
->setEnabled(false);
734 else if (count
== 1) {
735 // Only one file is selected. Pasting is only allowed if this
736 // file is a directory.
737 // TODO: this doesn't work with remote protocols; instead we need a
738 // m_activeView->selectedFileItems() to get the real KFileItems
739 const KFileItem
fileItem(S_IFDIR
,
743 pasteAction
->setEnabled(fileItem
.isDir());
748 void DolphinMainWindow::selectAll()
751 m_activeView
->selectAll();
754 void DolphinMainWindow::invertSelection()
757 m_activeView
->invertSelection();
759 void DolphinMainWindow::setIconsView()
761 m_activeView
->setMode(DolphinView::IconsView
);
764 void DolphinMainWindow::setDetailsView()
766 m_activeView
->setMode(DolphinView::DetailsView
);
769 void DolphinMainWindow::sortByName()
771 m_activeView
->setSorting(DolphinView::SortByName
);
774 void DolphinMainWindow::sortBySize()
776 m_activeView
->setSorting(DolphinView::SortBySize
);
779 void DolphinMainWindow::sortByDate()
781 m_activeView
->setSorting(DolphinView::SortByDate
);
784 void DolphinMainWindow::toggleSortOrder()
786 const Qt::SortOrder order
= (m_activeView
->sortOrder() == Qt::Ascending
) ?
789 m_activeView
->setSortOrder(order
);
792 void DolphinMainWindow::toggleSplitView()
794 if (m_view
[SecondaryIdx
] == 0) {
795 const int newWidth
= (m_view
[PrimaryIdx
]->width() - m_splitter
->handleWidth()) / 2;
796 // create a secondary view
797 m_view
[SecondaryIdx
] = new DolphinView(this,
799 m_view
[PrimaryIdx
]->url(),
800 m_view
[PrimaryIdx
]->mode(),
801 m_view
[PrimaryIdx
]->showHiddenFiles());
802 connectViewSignals(SecondaryIdx
);
803 m_splitter
->addWidget(m_view
[SecondaryIdx
]);
804 m_splitter
->setSizes(QList
<int>() << newWidth
<< newWidth
);
805 m_view
[SecondaryIdx
]->show();
808 // remove secondary view
809 if (m_activeView
== m_view
[PrimaryIdx
]) {
810 m_view
[SecondaryIdx
]->close();
811 m_view
[SecondaryIdx
]->deleteLater();
812 m_view
[SecondaryIdx
] = 0;
813 setActiveView(m_view
[PrimaryIdx
]);
816 // The secondary view is active, hence from the users point of view
817 // the content of the secondary view should be moved to the primary view.
818 // From an implementation point of view it is more efficient to close
819 // the primary view and exchange the internal pointers afterwards.
820 m_view
[PrimaryIdx
]->close();
821 delete m_view
[PrimaryIdx
];
822 m_view
[PrimaryIdx
] = m_view
[SecondaryIdx
];
823 m_view
[SecondaryIdx
] = 0;
824 setActiveView(m_view
[PrimaryIdx
]);
829 void DolphinMainWindow::reloadView()
832 m_activeView
->reload();
835 void DolphinMainWindow::stopLoading()
839 void DolphinMainWindow::togglePreview()
843 const KToggleAction
* showPreviewAction
=
844 static_cast<KToggleAction
*>(actionCollection()->action("show_preview"));
845 const bool show
= showPreviewAction
->isChecked();
846 m_activeView
->setShowPreview(show
);
849 void DolphinMainWindow::toggleShowHiddenFiles()
853 const KToggleAction
* showHiddenFilesAction
=
854 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
855 const bool show
= showHiddenFilesAction
->isChecked();
856 m_activeView
->setShowHiddenFiles(show
);
859 void DolphinMainWindow::showFilterBar()
861 const KToggleAction
* showFilterBarAction
=
862 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
863 const bool show
= showFilterBarAction
->isChecked();
864 m_activeView
->slotShowFilterBar(show
);
867 void DolphinMainWindow::zoomIn()
869 m_activeView
->zoomIn();
873 void DolphinMainWindow::zoomOut()
875 m_activeView
->zoomOut();
879 void DolphinMainWindow::toggleEditLocation()
883 KToggleAction
* action
= static_cast<KToggleAction
*>(actionCollection()->action("editable_location"));
885 bool editOrBrowse
= action
->isChecked();
886 // action->setChecked(action->setChecked);
887 m_activeView
->setUrlEditable(editOrBrowse
);
890 void DolphinMainWindow::editLocation()
892 KToggleAction
* action
= static_cast<KToggleAction
*>(actionCollection()->action("editable_location"));
893 action
->setChecked(true);
894 m_activeView
->setUrlEditable(true);
897 void DolphinMainWindow::adjustViewProperties()
900 ViewPropertiesDialog
dlg(m_activeView
);
904 void DolphinMainWindow::goBack()
907 m_activeView
->goBack();
910 void DolphinMainWindow::goForward()
913 m_activeView
->goForward();
916 void DolphinMainWindow::goUp()
919 m_activeView
->goUp();
922 void DolphinMainWindow::goHome()
925 m_activeView
->goHome();
928 void DolphinMainWindow::openTerminal()
930 QString
command("konsole --workdir \"");
931 command
.append(m_activeView
->url().path());
932 command
.append('\"');
934 KRun::runCommand(command
, "Konsole", "konsole");
937 void DolphinMainWindow::findFile()
939 KRun::run("kfind", m_activeView
->url());
942 void DolphinMainWindow::compareFiles()
944 // The method is only invoked if exactly 2 files have
945 // been selected. The selected files may be:
946 // - both in the primary view
947 // - both in the secondary view
948 // - one in the primary view and the other in the secondary
950 assert(m_view
[PrimaryIdx
] != 0);
954 KUrl::List urls
= m_view
[PrimaryIdx
]->selectedUrls();
956 switch (urls
.count()) {
958 assert(m_view
[SecondaryIdx
] != 0);
959 urls
= m_view
[SecondaryIdx
]->selectedUrls();
960 assert(urls
.count() == 2);
968 assert(m_view
[SecondaryIdx
] != 0);
969 urls
= m_view
[SecondaryIdx
]->selectedUrls();
970 assert(urls
.count() == 1);
982 // may not happen: compareFiles may only get invoked if 2
983 // files are selected
988 QString
command("kompare -c \"");
989 command
.append(urlA
.pathOrUrl());
990 command
.append("\" \"");
991 command
.append(urlB
.pathOrUrl());
992 command
.append('\"');
993 KRun::runCommand(command
, "Kompare", "kompare");
997 void DolphinMainWindow::editSettings()
999 // TODO: make a static method for opening the settings dialog
1000 DolphinSettingsDialog
dlg(this);
1004 void DolphinMainWindow::init()
1006 // Check whether Dolphin runs the first time. If yes then
1007 // a proper default window size is given at the end of DolphinMainWindow::init().
1008 GeneralSettings
* generalSettings
= DolphinSettings::instance().generalSettings();
1009 const bool firstRun
= generalSettings
->firstRun();
1011 setAcceptDrops(true);
1013 m_splitter
= new QSplitter(this);
1015 DolphinSettings
& settings
= DolphinSettings::instance();
1017 KBookmarkManager
* manager
= settings
.bookmarkManager();
1018 assert(manager
!= 0);
1019 KBookmarkGroup root
= manager
->root();
1020 if (root
.first().isNull()) {
1021 root
.addBookmark(manager
, i18n("Home"), settings
.generalSettings()->homeUrl(), "folder_home");
1022 root
.addBookmark(manager
, i18n("Storage Media"), KUrl("media:/"), "blockdevice");
1023 root
.addBookmark(manager
, i18n("Network"), KUrl("remote:/"), "network_local");
1024 root
.addBookmark(manager
, i18n("Root"), KUrl("/"), "folder_red");
1025 root
.addBookmark(manager
, i18n("Trash"), KUrl("trash:/"), "trashcan_full");
1030 const KUrl
& homeUrl
= root
.first().url();
1031 setCaption(homeUrl
.fileName());
1032 ViewProperties
props(homeUrl
);
1033 m_view
[PrimaryIdx
] = new DolphinView(this,
1037 props
.showHiddenFiles());
1038 connectViewSignals(PrimaryIdx
);
1039 m_view
[PrimaryIdx
]->show();
1041 m_activeView
= m_view
[PrimaryIdx
];
1043 setCentralWidget(m_splitter
);
1046 setupGUI(Keys
|Save
|Create
|ToolBar
);
1049 stateChanged("new_file");
1050 setAutoSaveSettings();
1052 QClipboard
* clipboard
= QApplication::clipboard();
1053 connect(clipboard
, SIGNAL(dataChanged()),
1054 this, SLOT(updatePasteAction()));
1055 updatePasteAction();
1058 setupCreateNewMenuActions();
1063 // assure a proper default size if Dolphin runs the first time
1068 void DolphinMainWindow::loadSettings()
1070 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
1072 KToggleAction
* splitAction
= static_cast<KToggleAction
*>(actionCollection()->action("split_view"));
1073 if (settings
->splitView()) {
1074 splitAction
->setChecked(true);
1078 updateViewActions();
1080 // TODO: I assume there will be a generic way in KDE 4 to restore the docks
1081 // of the main window. In the meantime they are restored manually (see also
1082 // DolphinMainWindow::closeEvent() for more details):
1083 QString filename
= KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName());
1084 filename
.append("/panels_layout");
1085 QFile
file(filename
);
1086 if (file
.open(QIODevice::ReadOnly
)) {
1087 QByteArray data
= file
.readAll();
1093 void DolphinMainWindow::setupActions()
1095 // setup 'File' menu
1096 QAction
*action
= actionCollection()->addAction("new_window");
1097 action
->setIcon(KIcon("window_new"));
1098 action
->setText(i18n("New &Window"));
1099 connect(action
, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
1101 QAction
* createFolder
= actionCollection()->addAction("create_folder");
1102 createFolder
->setText(i18n("Folder..."));
1103 createFolder
->setIcon(KIcon("folder"));
1104 createFolder
->setShortcut(Qt::Key_N
);
1105 connect(createFolder
, SIGNAL(triggered()), this, SLOT(createFolder()));
1107 QAction
* rename
= actionCollection()->addAction("rename");
1108 rename
->setText(i18n("Rename"));
1109 rename
->setShortcut(Qt::Key_F2
);
1110 connect(rename
, SIGNAL(triggered()), this, SLOT(rename()));
1112 QAction
* moveToTrash
= actionCollection()->addAction("move_to_trash");
1113 moveToTrash
->setText(i18n("Move to Trash"));
1114 moveToTrash
->setIcon(KIcon("edittrash"));
1115 moveToTrash
->setShortcut(QKeySequence::Delete
);
1116 connect(moveToTrash
, SIGNAL(triggered()), this, SLOT(moveToTrash()));
1118 QAction
* deleteAction
= actionCollection()->addAction("delete");
1119 deleteAction
->setText(i18n("Delete"));
1120 deleteAction
->setShortcut(Qt::ALT
| Qt::Key_Delete
);
1121 deleteAction
->setIcon(KIcon("editdelete"));
1122 connect(deleteAction
, SIGNAL(triggered()), this, SLOT(deleteItems()));
1124 QAction
* properties
= actionCollection()->addAction("properties");
1125 properties
->setText(i18n("Propert&ies"));
1126 properties
->setShortcut(Qt::Key_Alt
| Qt::Key_Return
);
1127 connect(properties
, SIGNAL(triggered()), this, SLOT(properties()));
1129 KStandardAction::quit(this, SLOT(quit()), actionCollection());
1131 // setup 'Edit' menu
1132 KStandardAction::undo(KonqUndoManager::self(),
1134 actionCollection());
1136 KStandardAction::cut(this, SLOT(cut()), actionCollection());
1137 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1138 KStandardAction::paste(this, SLOT(paste()), actionCollection());
1140 QAction
* selectAll
= actionCollection()->addAction("select_all");
1141 selectAll
->setText(i18n("Select All"));
1142 selectAll
->setShortcut(Qt::CTRL
+ Qt::Key_A
);
1143 connect(selectAll
, SIGNAL(triggered()), this, SLOT(selectAll()));
1145 QAction
* invertSelection
= actionCollection()->addAction("invert_selection");
1146 invertSelection
->setText(i18n("Invert Selection"));
1147 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1148 connect(invertSelection
, SIGNAL(triggered()), this, SLOT(invertSelection()));
1150 // setup 'View' menu
1151 KStandardAction::zoomIn(this,
1153 actionCollection());
1155 KStandardAction::zoomOut(this,
1157 actionCollection());
1159 KToggleAction
* iconsView
= actionCollection()->add
<KToggleAction
>("icons");
1160 iconsView
->setText(i18n("Icons"));
1161 iconsView
->setShortcut(Qt::CTRL
| Qt::Key_1
);
1162 iconsView
->setIcon(KIcon("view_icon"));
1163 connect(iconsView
, SIGNAL(triggered()), this, SLOT(setIconsView()));
1165 KToggleAction
* detailsView
= actionCollection()->add
<KToggleAction
>("details");
1166 detailsView
->setText(i18n("Details"));
1167 detailsView
->setShortcut(Qt::CTRL
| Qt::Key_2
);
1168 detailsView
->setIcon(KIcon("view_text"));
1169 connect(detailsView
, SIGNAL(triggered()), this, SLOT(setDetailsView()));
1171 QActionGroup
* viewModeGroup
= new QActionGroup(this);
1172 viewModeGroup
->addAction(iconsView
);
1173 viewModeGroup
->addAction(detailsView
);
1175 KToggleAction
* sortByName
= actionCollection()->add
<KToggleAction
>("by_name");
1176 sortByName
->setText(i18n("By Name"));
1177 connect(sortByName
, SIGNAL(triggered()), this, SLOT(sortByName()));
1179 KToggleAction
* sortBySize
= actionCollection()->add
<KToggleAction
>("by_size");
1180 sortBySize
->setText(i18n("By Size"));
1181 connect(sortBySize
, SIGNAL(triggered()), this, SLOT(sortBySize()));
1183 KToggleAction
* sortByDate
= actionCollection()->add
<KToggleAction
>("by_date");
1184 sortByDate
->setText(i18n("By Date"));
1185 connect(sortByDate
, SIGNAL(triggered()), this, SLOT(sortByDate()));
1187 QActionGroup
* sortGroup
= new QActionGroup(this);
1188 sortGroup
->addAction(sortByName
);
1189 sortGroup
->addAction(sortBySize
);
1190 sortGroup
->addAction(sortByDate
);
1192 KToggleAction
* sortDescending
= actionCollection()->add
<KToggleAction
>("descending");
1193 sortDescending
->setText(i18n("Descending"));
1194 connect(sortDescending
, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
1196 KToggleAction
* showPreview
= actionCollection()->add
<KToggleAction
>("show_preview");
1197 showPreview
->setText(i18n("Show Preview"));
1198 connect(showPreview
, SIGNAL(triggered()), this, SLOT(togglePreview()));
1200 KToggleAction
* showHiddenFiles
= actionCollection()->add
<KToggleAction
>("show_hidden_files");
1201 showHiddenFiles
->setText(i18n("Show Hidden Files"));
1202 //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'?
1203 connect(showHiddenFiles
, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
1205 KToggleAction
* split
= actionCollection()->add
<KToggleAction
>("split_view");
1206 split
->setText(i18n("Split View"));
1207 split
->setShortcut(Qt::Key_F10
);
1208 split
->setIcon(KIcon("view_left_right"));
1209 connect(split
, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1211 QAction
* reload
= actionCollection()->addAction("reload");
1212 reload
->setText(i18n("Reload"));
1213 reload
->setShortcut(Qt::Key_F5
);
1214 reload
->setIcon(KIcon("reload"));
1215 connect(reload
, SIGNAL(triggered()), this, SLOT(reloadView()));
1217 QAction
* stop
= actionCollection()->addAction("stop");
1218 stop
->setText(i18n("Stop"));
1219 stop
->setIcon(KIcon("stop"));
1220 connect(stop
, SIGNAL(triggered()), this, SLOT(stopLoading()));
1222 KToggleAction
* showFullLocation
= actionCollection()->add
<KToggleAction
>("editable_location");
1223 showFullLocation
->setText(i18n("Show Full Location"));
1224 showFullLocation
->setShortcut(Qt::CTRL
| Qt::Key_L
);
1225 connect(showFullLocation
, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1227 KToggleAction
* editLocation
= actionCollection()->add
<KToggleAction
>("edit_location");
1228 editLocation
->setText(i18n("Edit Location"));
1229 editLocation
->setShortcut(Qt::Key_F6
);
1230 connect(editLocation
, SIGNAL(triggered()), this, SLOT(editLocation()));
1232 QAction
* adjustViewProps
= actionCollection()->addAction("view_properties");
1233 adjustViewProps
->setText(i18n("Adjust View Properties..."));
1234 connect(adjustViewProps
, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
1237 KStandardAction::back(this, SLOT(goBack()), actionCollection());
1238 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1239 KStandardAction::up(this, SLOT(goUp()), actionCollection());
1240 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1242 // setup 'Tools' menu
1243 QAction
* openTerminal
= actionCollection()->addAction("open_terminal");
1244 openTerminal
->setText(i18n("Open Terminal"));
1245 openTerminal
->setShortcut(Qt::Key_F4
);
1246 openTerminal
->setIcon(KIcon("konsole"));
1247 connect(openTerminal
, SIGNAL(triggered()), this, SLOT(openTerminal()));
1249 QAction
* findFile
= actionCollection()->addAction("find_file");
1250 findFile
->setText(i18n("Find File..."));
1251 findFile
->setShortcut(Qt::Key_F
);
1252 findFile
->setIcon(KIcon("filefind"));
1253 connect(findFile
, SIGNAL(triggered()), this, SLOT(findFile()));
1255 KToggleAction
* showFilterBar
= actionCollection()->add
<KToggleAction
>("show_filter_bar");
1256 showFilterBar
->setText(i18n("Show Filter Bar"));
1257 showFilterBar
->setShortcut(Qt::Key_Slash
);
1258 connect(showFilterBar
, SIGNAL(triggered()), this, SLOT(showFilterBar()));
1260 QAction
* compareFiles
= actionCollection()->addAction("compare_files");
1261 compareFiles
->setText(i18n("Compare Files"));
1262 compareFiles
->setIcon(KIcon("kompare"));
1263 compareFiles
->setEnabled(false);
1264 connect(compareFiles
, SIGNAL(triggered()), this, SLOT(compareFiles()));
1266 // setup 'Settings' menu
1267 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1270 void DolphinMainWindow::setupDockWidgets()
1272 QDockWidget
* shortcutsDock
= new QDockWidget(i18n("Bookmarks"));
1273 shortcutsDock
->setObjectName("bookmarksDock");
1274 shortcutsDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1275 shortcutsDock
->setWidget(new BookmarksSidebarPage(this));
1277 shortcutsDock
->toggleViewAction()->setText(i18n("Show Bookmarks Panel"));
1278 actionCollection()->addAction("show_bookmarks_panel", shortcutsDock
->toggleViewAction());
1280 addDockWidget(Qt::LeftDockWidgetArea
, shortcutsDock
);
1282 QDockWidget
* infoDock
= new QDockWidget(i18n("Information"));
1283 infoDock
->setObjectName("infoDock");
1284 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1285 infoDock
->setWidget(new InfoSidebarPage(this));
1287 infoDock
->toggleViewAction()->setText(i18n("Show Information Panel"));
1288 actionCollection()->addAction("show_info_panel", infoDock
->toggleViewAction());
1290 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1293 void DolphinMainWindow::setupCreateNewMenuActions()
1295 // Parts of the following code have been taken
1296 // from the class KNewMenu located in
1297 // libqonq/knewmenu.h of Konqueror.
1298 // Copyright (C) 1998, 1999 David Faure <faure@kde.org>
1299 // 2003 Sven Leiber <s.leiber@web.de>
1301 QStringList files
= actionCollection()->instance()->dirs()->findAllResources("templates");
1302 for (QStringList::Iterator it
= files
.begin() ; it
!= files
.end(); ++it
) {
1303 if ((*it
)[0] != '.' ) {
1304 KSimpleConfig
config(*it
, true);
1305 config
.setDesktopGroup();
1307 // tricky solution to ensure that TextFile is at the beginning
1308 // because this filetype is the most used (according kde-core discussion)
1309 const QString
name(config
.readEntry("Name"));
1312 const QString
path(config
.readPathEntry("Url"));
1313 if (!path
.endsWith("emptydir")) {
1314 if (path
.endsWith("TextFile.txt")) {
1317 else if (!KDesktopFile::isDesktopFile(path
)) {
1320 else if (path
.endsWith("Url.desktop")){
1323 else if (path
.endsWith("Program.desktop")){
1330 const QString
icon(config
.readEntry("Icon"));
1331 const QString
comment(config
.readEntry("Comment"));
1332 const QString
type(config
.readEntry("Type"));
1334 const QString
filePath(*it
);
1337 if (type
== "Link") {
1338 CreateFileEntry entry
;
1341 entry
.comment
= comment
;
1342 entry
.templatePath
= filePath
;
1343 m_createFileTemplates
.insert(key
, entry
);
1348 m_createFileTemplates
.sort();
1350 unplugActionList("create_actions");
1351 KSortableList
<CreateFileEntry
, QString
>::ConstIterator it
= m_createFileTemplates
.begin();
1352 KSortableList
<CreateFileEntry
, QString
>::ConstIterator end
= m_createFileTemplates
.end();
1353 /* KDE4-TODO: don't port this code; use KNewMenu instead
1355 CreateFileEntry entry = (*it).value();
1356 KAction* action = new KAction(entry.name);
1357 action->setIcon(entry.icon);
1358 action->setName((*it).index());
1359 connect(action, SIGNAL(activated()),
1360 this, SLOT(createFile()));
1362 const QChar section = ((*it).index()[0]);
1366 m_fileGroupActions.append(action);
1372 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
1373 // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
1374 //m_linkGroupActions.append(action);
1379 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
1380 // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
1381 //m_linkToDeviceActions.append(action);
1390 plugActionList("create_file_group", m_fileGroupActions);
1391 //plugActionList("create_link_group", m_linkGroupActions);
1392 //plugActionList("link_to_device", m_linkToDeviceActions);*/
1395 void DolphinMainWindow::updateHistory()
1398 const Q3ValueList
<UrlNavigator::HistoryElem
> list
= m_activeView
->urlHistory(index
);
1400 QAction
* backAction
= actionCollection()->action("go_back");
1401 if (backAction
!= 0) {
1402 backAction
->setEnabled(index
< static_cast<int>(list
.count()) - 1);
1405 QAction
* forwardAction
= actionCollection()->action("go_forward");
1406 if (forwardAction
!= 0) {
1407 forwardAction
->setEnabled(index
> 0);
1411 void DolphinMainWindow::updateEditActions()
1413 const KFileItemList list
= m_activeView
->selectedItems();
1414 if (list
.isEmpty()) {
1415 stateChanged("has_no_selection");
1418 stateChanged("has_selection");
1420 QAction
* renameAction
= actionCollection()->action("rename");
1421 if (renameAction
!= 0) {
1422 renameAction
->setEnabled(list
.count() >= 1);
1425 bool enableMoveToTrash
= true;
1427 KFileItemList::const_iterator it
= list
.begin();
1428 const KFileItemList::const_iterator end
= list
.end();
1430 KFileItem
* item
= *it
;
1431 const KUrl
& url
= item
->url();
1432 // only enable the 'Move to Trash' action for local files
1433 if (!url
.isLocalFile()) {
1434 enableMoveToTrash
= false;
1439 QAction
* moveToTrashAction
= actionCollection()->action("move_to_trash");
1440 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1442 updatePasteAction();
1445 void DolphinMainWindow::updateViewActions()
1447 QAction
* zoomInAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn
));
1448 if (zoomInAction
!= 0) {
1449 zoomInAction
->setEnabled(m_activeView
->isZoomInPossible());
1452 QAction
* zoomOutAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut
));
1453 if (zoomOutAction
!= 0) {
1454 zoomOutAction
->setEnabled(m_activeView
->isZoomOutPossible());
1457 QAction
* action
= 0;
1458 switch (m_activeView
->mode()) {
1459 case DolphinView::IconsView
:
1460 action
= actionCollection()->action("icons");
1462 case DolphinView::DetailsView
:
1463 action
= actionCollection()->action("details");
1465 //case DolphinView::PreviewsView:
1466 // action = actionCollection()->action("previews");
1473 KToggleAction
* toggleAction
= static_cast<KToggleAction
*>(action
);
1474 toggleAction
->setChecked(true);
1477 slotSortingChanged(m_activeView
->sorting());
1478 slotSortOrderChanged(m_activeView
->sortOrder());
1480 KToggleAction
* showFilterBarAction
=
1481 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
1482 showFilterBarAction
->setChecked(m_activeView
->isFilterBarVisible());
1484 KToggleAction
* showHiddenFilesAction
=
1485 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
1486 showHiddenFilesAction
->setChecked(m_activeView
->showHiddenFiles());
1488 KToggleAction
* splitAction
= static_cast<KToggleAction
*>(actionCollection()->action("split_view"));
1489 splitAction
->setChecked(m_view
[SecondaryIdx
] != 0);
1492 void DolphinMainWindow::updateGoActions()
1494 QAction
* goUpAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Up
));
1495 const KUrl
& currentUrl
= m_activeView
->url();
1496 goUpAction
->setEnabled(currentUrl
.upUrl() != currentUrl
);
1499 void DolphinMainWindow::copyUrls(const KUrl::List
& source
, const KUrl
& dest
)
1501 KonqOperations::copy(this, KonqOperations::COPY
, source
, dest
);
1502 m_undoOperations
.append(KonqOperations::COPY
);
1505 void DolphinMainWindow::moveUrls(const KUrl::List
& source
, const KUrl
& dest
)
1507 KonqOperations::copy(this, KonqOperations::MOVE
, source
, dest
);
1508 m_undoOperations
.append(KonqOperations::MOVE
);
1511 void DolphinMainWindow::clearStatusBar()
1513 m_activeView
->statusBar()->clear();
1516 void DolphinMainWindow::connectViewSignals(int viewIndex
)
1518 DolphinView
* view
= m_view
[viewIndex
];
1519 connect(view
, SIGNAL(modeChanged()),
1520 this, SLOT(slotViewModeChanged()));
1521 connect(view
, SIGNAL(showHiddenFilesChanged()),
1522 this, SLOT(slotShowHiddenFilesChanged()));
1523 connect(view
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
1524 this, SLOT(slotSortingChanged(DolphinView::Sorting
)));
1525 connect(view
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
1526 this, SLOT(slotSortOrderChanged(Qt::SortOrder
)));
1527 connect(view
, SIGNAL(selectionChanged()),
1528 this, SLOT(slotSelectionChanged()));
1529 connect(view
, SIGNAL(showFilterBarChanged(bool)),
1530 this, SLOT(updateFilterBarAction(bool)));
1532 const UrlNavigator
* navigator
= view
->urlNavigator();
1533 connect(navigator
, SIGNAL(urlChanged(const KUrl
&)),
1534 this, SLOT(slotUrlChanged(const KUrl
&)));
1535 connect(navigator
, SIGNAL(historyChanged()),
1536 this, SLOT(slotHistoryChanged()));
1540 #include "dolphinmainwindow.moc"