#include "panels/information/informationpanel.h"
#include "settings/dolphinsettingsdialog.h"
#include "statusbar/dolphinstatusbar.h"
+#include "views/dolphinview.h"
#include "views/dolphinviewactionhandler.h"
#include "views/dolphinremoteencoding.h"
#include "views/draganddrophelper.h"
#include "views/viewproperties.h"
+#include "views/dolphinnewfilemenuobserver.h"
#ifndef Q_OS_WIN
#include "panels/terminal/terminalpanel.h"
ViewTab& viewTab = m_viewTab[m_tabIndex];
viewTab.wasActive = true; // The first opened tab is automatically active
+ connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
+ this, SLOT(showErrorMessage(QString)));
+
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
undoManager->setUiInterface(new UndoUiInterface());
return;
}
- if (dirs.count() == 1) {
- m_activeViewContainer->setUrl(dirs.first());
+ // dirs could contain URLs that actually point to archives or other files.
+ // Replace them by URLs we can open where possible and filter the rest out.
+ QList<KUrl> urlsToOpen;
+ foreach (const KUrl& rawUrl, dirs) {
+ const KFileItem& item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, rawUrl);
+ item.determineMimeType();
+ const KUrl& url = DolphinView::openItemAsFolderUrl(item);
+ if (!url.isEmpty()) {
+ urlsToOpen.append(url);
+ }
+ }
+
+ if (urlsToOpen.count() == 1) {
+ m_activeViewContainer->setUrl(urlsToOpen.first());
return;
}
// Open each directory inside a new tab. If the "split view" option has been enabled,
// always show two directories within one tab.
- QList<KUrl>::const_iterator it = dirs.begin();
- while (it != dirs.end()) {
+ QList<KUrl>::const_iterator it = urlsToOpen.constBegin();
+ while (it != urlsToOpen.constEnd()) {
openNewTab(*it);
++it;
- if (hasSplitView && (it != dirs.end())) {
+ if (hasSplitView && (it != urlsToOpen.constEnd())) {
const int tabIndex = m_viewTab.count() - 1;
m_viewTab[tabIndex].secondaryView->setUrl(*it);
++it;
void DolphinMainWindow::compareFiles()
{
- // The method is only invoked if exactly 2 files have
- // been selected. The selected files may be:
- // - both in the primary view
- // - both in the secondary view
- // - one in the primary view and the other in the secondary
- // view
- Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
-
- KUrl urlA;
- KUrl urlB;
+ const DolphinViewContainer* primaryViewContainer = m_viewTab[m_tabIndex].primaryView;
+ Q_ASSERT(primaryViewContainer);
+ KFileItemList items = primaryViewContainer->view()->selectedItems();
- KFileItemList items = m_viewTab[m_tabIndex].primaryView->view()->selectedItems();
-
- switch (items.count()) {
- case 0: {
- Q_ASSERT(m_viewTab[m_tabIndex].secondaryView);
- items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems();
- Q_ASSERT(items.count() == 2);
- urlA = items[0].url();
- urlB = items[1].url();
- break;
- }
-
- case 1: {
- urlA = items[0].url();
- Q_ASSERT(m_viewTab[m_tabIndex].secondaryView);
- items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems();
- Q_ASSERT(items.count() == 1);
- urlB = items[0].url();
- break;
+ const DolphinViewContainer* secondaryViewContainer = m_viewTab[m_tabIndex].secondaryView;
+ if (secondaryViewContainer) {
+ items.append(secondaryViewContainer->view()->selectedItems());
}
- case 2: {
- urlA = items[0].url();
- urlB = items[1].url();
- break;
+ if (items.count() != 2) {
+ // The action is disabled in this case, but it could have been triggered
+ // via D-Bus, see https://bugs.kde.org/show_bug.cgi?id=325517
+ return;
}
- default: {
- // may not happen: compareFiles may only get invoked if 2
- // files are selected
- Q_ASSERT(false);
- }
- }
+ KUrl urlA = items.at(0).url();
+ KUrl urlB = items.at(1).url();
QString command("kompare -c \"");
command.append(urlA.pathOrUrl());
{
QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
contextMenu.data()->setCustomActions(customActions);
- connect(contextMenu.data(), SIGNAL(errorMessage(QString)),
- this, SLOT(showErrorMessage(QString)));
const DolphinContextMenu::Command command = contextMenu.data()->open();
switch (command) {
activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
}
+void DolphinMainWindow::slotPlaceActivated(const KUrl& url)
+{
+ DolphinViewContainer* view = activeViewContainer();
+
+ if (view->url() == url) {
+ // We can end up here if the user clicked a device in the Places Panel
+ // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
+ reloadView();
+ } else {
+ changeUrl(url);
+ }
+}
+
void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
{
Q_ASSERT(viewContainer);
m_newFileMenu->setDelayed(false);
connect(menu, SIGNAL(aboutToShow()),
this, SLOT(updateNewMenu()));
- connect(m_newFileMenu, SIGNAL(errorMessage(QString)),
- this, SLOT(showErrorMessage(QString)));
KAction* newWindow = actionCollection()->addAction("new_window");
newWindow->setIcon(KIcon("window-new"));
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
connect(placesPanel, SIGNAL(placeActivated(KUrl)),
- this, SLOT(changeUrl(KUrl)));
+ this, SLOT(slotPlaceActivated(KUrl)));
connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
this, SLOT(openNewTab(KUrl)));
connect(placesPanel, SIGNAL(errorMessage(QString)),